Put current page path into hyperlink?

  • Thread starter Thread starter Amil
  • Start date Start date
A

Amil

I have a page with a hyperlink (actually in a datalist). I want the
URL to do a postback essentially. I tried to use Page.Request in
the NavigateUrl, but it's always empty? How do I tell it to use the
current page url for the url?

<asp:DataList id="dlstItems" runat="server" OnItemCommand="OnItemCommand"
SelectedIndex="0">
<ItemTemplate>
<asp:HyperLink NavigateUrl="<%# Request.Path %>" Runat="server">
MyLinkText</asp:HyperLink>
</ItemTemplate>
..
..
..
 
use an <asp:linkbutton> for that if you are trying to get a postback, it'll
set all that postback stuff up for you automatically, but still render it as
a hyperlink. You can also take advantage of the commandname/commandargument
properties so the postback'd page knows what to do.
 
Back
Top