Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default Header Control

    This is one that has had me puzzled for some time and although I assume that
    the solution is relatively straight forward but I haven't yet seen an
    example or solution or managed to work one out.

    If you create a user control for header, navbar etc the hyperlinks only work
    if the relative location is correct for all the pages using the user
    control. I am aware that using the asp:hyperlink control you can set the
    link information within the code (I'm using VB.Net). However the MapPath
    statement provides a path to the drive letter which is not particularly
    useful in passing to a hyperlink. I know that the ResolveURL calculates
    relative URL's but I don't seem to be able to apply that to the MapPath
    option.

    Once again I am sure that there is a simple solution but I do find it
    strange that I have never seen it implicated on any sample code etc.

    All help appreciated.

    Martyn Fewtrell
    [email]mfewtrell@networkclub.co.uk[/email]



    Martyn Fewtrell Guest

  2. Similar Questions and Discussions

    1. access control in header template
      I got a label control which is dynamically created inside the headerTemplate of template column. And it is part of the datagrid. Please teach...
    2. Sorting link disappear when put control in the header
      HI guys, I have a datagrid with 5 coloums. What I want to achive is put a button or a checkbox into each header of the coloums and when fires an...
    3. get more control on datagrid header (?)
      Dear all, I add more header's row on runtime using ItemCreate() and add DataGridItem(0, 0, ListItemType.Header) to get more header row. and...
    4. Header, Footer, Content Templated Control
      I realize this question has been asked in many different newsgroups, but reading through these discussions and the vague examples that come with...
    5. Problem to Access web control on the DataGrid Header
      Hi The Items Collection of DataGrid does not hold Header and Footer. So to access the Control you need to handle ItemCreated event. HTH...
  3. #2

    Default Re: Header Control

    Hi Martyn,

    The method I use to apply the correct path for navigation components
    is this:

    In the global.asax file, in the Session_Start Event, I do the
    following:

    If (Application.Item("ApplicationPath") = "") Then
    Dim strApplication As String = Request.ApplicationPath
    If (Right(strApplicationPath, 1) <> "/") Then strApplicationPath
    &= "/"
    Application.Item.Add("ApplicationPath", strApplicationPath)
    End If

    Then, in your user control, you set the path on your hyperlink
    controls using the stored application path in the Application
    collection:

    Hyperlink1.NavigateURL = Application.Item("ApplicationPath") &
    "somepath/"

    Note that the path in the "ApplicationPath" variable already contains
    the trailing slash. It's a shame that the Request.ApplicationPath
    variable doesn't return a properly terminated path (with a slash at
    the end) when you're working with a virtual directory. It would have
    been much simpler to use Request.ApplicationPath directly in the user
    control instead.

    HTH

    Éric

    "Martyn Fewtrell" <mfewtrell@networkclub.co.uk> wrote in message
    news:%23fWeS$pMEHA.2640@TK2MSFTNGP12.phx.gbl...
    > This is one that has had me puzzled for some time and although I
    assume that
    > the solution is relatively straight forward but I haven't yet seen
    an
    > example or solution or managed to work one out.
    >
    > If you create a user control for header, navbar etc the hyperlinks
    only work
    > if the relative location is correct for all the pages using the user
    > control. I am aware that using the asp:hyperlink control you can set
    the
    > link information within the code (I'm using VB.Net). However the
    MapPath
    > statement provides a path to the drive letter which is not
    particularly
    > useful in passing to a hyperlink. I know that the ResolveURL
    calculates
    > relative URL's but I don't seem to be able to apply that to the
    MapPath
    > option.
    >
    > Once again I am sure that there is a simple solution but I do find
    it
    > strange that I have never seen it implicated on any sample code etc.
    >
    > All help appreciated.
    >
    > Martyn Fewtrell
    > [email]mfewtrell@networkclub.co.uk[/email]
    >

    Eric Caron Guest

  4. #3

    Default Re: Header Control

    Eric

    Thanks for your response.

    It seems surprising that this must be a very common issue although I have
    not found much information regarding the problem. Since posting the message
    I have found that

    hyperlink.NavigateUrl = ResolveUrl("../mypage.aspx")

    seems to work. I certainly haven't tested this extensively but it seems OK
    on my development machine.

    Martyn Fewtrell
    [email]mfewtrell@networkclub.co.uk[/email]



    "Eric Caron" <eric.caron@spamsucks.videotron.ca> wrote in message
    news:O%23CQPKhOEHA.2480@tk2msftngp13.phx.gbl...
    > Hi Martyn,
    >
    > The method I use to apply the correct path for navigation components
    > is this:
    >
    > In the global.asax file, in the Session_Start Event, I do the
    > following:
    >
    > If (Application.Item("ApplicationPath") = "") Then
    > Dim strApplication As String = Request.ApplicationPath
    > If (Right(strApplicationPath, 1) <> "/") Then strApplicationPath
    > &= "/"
    > Application.Item.Add("ApplicationPath", strApplicationPath)
    > End If
    >
    > Then, in your user control, you set the path on your hyperlink
    > controls using the stored application path in the Application
    > collection:
    >
    > Hyperlink1.NavigateURL = Application.Item("ApplicationPath") &
    > "somepath/"
    >
    > Note that the path in the "ApplicationPath" variable already contains
    > the trailing slash. It's a shame that the Request.ApplicationPath
    > variable doesn't return a properly terminated path (with a slash at
    > the end) when you're working with a virtual directory. It would have
    > been much simpler to use Request.ApplicationPath directly in the user
    > control instead.
    >
    > HTH
    >
    > Éric
    >
    > "Martyn Fewtrell" <mfewtrell@networkclub.co.uk> wrote in message
    > news:%23fWeS$pMEHA.2640@TK2MSFTNGP12.phx.gbl...
    > > This is one that has had me puzzled for some time and although I
    > assume that
    > > the solution is relatively straight forward but I haven't yet seen
    > an
    > > example or solution or managed to work one out.
    > >
    > > If you create a user control for header, navbar etc the hyperlinks
    > only work
    > > if the relative location is correct for all the pages using the user
    > > control. I am aware that using the asp:hyperlink control you can set
    > the
    > > link information within the code (I'm using VB.Net). However the
    > MapPath
    > > statement provides a path to the drive letter which is not
    > particularly
    > > useful in passing to a hyperlink. I know that the ResolveURL
    > calculates
    > > relative URL's but I don't seem to be able to apply that to the
    > MapPath
    > > option.
    > >
    > > Once again I am sure that there is a simple solution but I do find
    > it
    > > strange that I have never seen it implicated on any sample code etc.
    > >
    > > All help appreciated.
    > >
    > > Martyn Fewtrell
    > > [email]mfewtrell@networkclub.co.uk[/email]
    > >
    >
    >

    Martyn Fewtrell Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139