Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

ASP.net Sitemap with link to open in new window

  • 11-11-2008 2:55pm
    #1
    Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭


    Hi,

    I'm very surprised to see that the ASP.net Sitemap control does not allow for the target="_blank" attribute.

    I have an external link and need to open it on a new page. Anyone overcome this problem before?

    Thanks in advance,
    John


Comments

  • Registered Users, Registered Users 2 Posts: 2,894 ✭✭✭TinCool


    I have used the below code in one of my apps to open a link in a new window with a bit of client side javascript from a button click event.
        Protected Sub btnBrandedNumbers_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnBrandedNumbers.Click
            Dim RedirectURL As String = "[URL]http://yourwebsite/Default.aspx[/URL]"
            Dim RedirectNewWindow As String = "<SCRIPT LANGUAGE=""JavaScript"">window.open('" + RedirectURL + "','_blank');</SCRIPT>"
            ClientScript.RegisterClientScriptBlock(Me.GetType(), "ClientScript", RedirectNewWindow)
        End Sub
    


  • Registered Users, Registered Users 2 Posts: 610 ✭✭✭nialo


    This has worked for me... Bind sitemap to a Menu control and use the following.
    protected void MenuBar_MenuItemDataBound(object sender, MenuEventArgs e)
    {
    e.Item.Target = "_blank";
    }
    


  • Registered Users, Registered Users 2 Posts: 21,263 ✭✭✭✭Eoin


    Can you set the link target in the header tag for the site map?


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    TinCool wrote: »
    I have used the below code in one of my apps to open a link in a new window with a bit of client side javascript from a button click event.
        Protected Sub btnBrandedNumbers_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnBrandedNumbers.Click
            Dim RedirectURL As String = "[URL]http://yourwebsite/Default.aspx[/URL]"
            Dim RedirectNewWindow As String = "<SCRIPT LANGUAGE=""JavaScript"">window.open('" + RedirectURL + "','_blank');</SCRIPT>"
            ClientScript.RegisterClientScriptBlock(Me.GetType(), "ClientScript", RedirectNewWindow)
        End Sub
    

    Thanks for the reply but would like to avoid injecting JS.
    nialo wrote: »
    This has worked for me... Bind sitemap to a Menu control and use the following.
    protected void MenuBar_MenuItemDataBound(object sender, MenuEventArgs e)
    {
    e.Item.Target = "_blank";
    }
    

    Thanks, will try this out now!
    eoin_s wrote: »
    Can you set the link target in the header tag for the site map?

    I don't believe so, at least my good friend Google didnt come back with anything like that. And the MSDN didnt mention anything either


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    In the sitemap.xml

    <siteMapNode url="Home.aspx" title="Home" target="_blank">

    For example will launch in a new window

    http://weblogs.asp.net/dannychen/archive/2005/03/28/396099.aspx


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Ginger wrote: »
    In the sitemap.xml

    <siteMapNode url="Home.aspx" title="Home" target="_blank">

    For example will launch in a new window

    http://weblogs.asp.net/dannychen/archive/2005/03/28/396099.aspx

    Thanks! As I already said, it's a bit crazy that they didnt provide for this type of functionality out of the box :confused:


Advertisement