Ask a Question related to ASP.NET Building Controls, Design and Development.
-
Martyn Fewtrell #1
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
-
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... -
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... -
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... -
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... -
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... -
Eric Caron #2
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...assume that> This is one that has had me puzzled for some time and although Ian> the solution is relatively straight forward but I haven't yet seenonly work> example or solution or managed to work one out.
>
> If you create a user control for header, navbar etc the hyperlinksthe> 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 setMapPath> link information within the code (I'm using VB.Net). However theparticularly> statement provides a path to the drive letter which is notcalculates> useful in passing to a hyperlink. I know that the ResolveURLMapPath> relative URL's but I don't seem to be able to apply that to theit> option.
>
> Once again I am sure that there is a simple solution but I do find> 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
-
Martyn Fewtrell #3
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...> assume that> > This is one that has had me puzzled for some time and although I> an> > the solution is relatively straight forward but I haven't yet seen> only work> > example or solution or managed to work one out.
> >
> > If you create a user control for header, navbar etc the hyperlinks> the> > 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> MapPath> > link information within the code (I'm using VB.Net). However the> particularly> > statement provides a path to the drive letter which is not> calculates> > useful in passing to a hyperlink. I know that the ResolveURL> MapPath> > relative URL's but I don't seem to be able to apply that to the> it> > option.
> >
> > Once again I am sure that there is a simple solution but I do find>> > 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



Reply With Quote

