asp.net - How to include Session variable in NavigateUrl in hyperlink -
I'm sure I did it before, but can not remember the syntax. How do I include nagivateUrl session sessions in hyperlinks?
I have tried to:
& lt; Asp: hyperlink id = "lnkMyLink" runat = "server" text = "my link" navigate URL = '& lt;% #' 'http://absoluteURL.org?param= "+ session [" MyPamater Well "]. Toasting ()% & gt; ' & Gt; & lt; / asp: hyperlink & gt;
and this:
asp: hyperlink id = "lnkMyLink" runat = Navigate to "server" text = "my link" = url = '& lt;% # String.Format ("http://absoluteURL.org?param={0}", session ["myParameterValue"]. ToString ()) %> Gt; & gt; & lt; / asp: HyperLink & gt;
Because you have used the data binding format ( & lt;% #
), you need to call the hyperlink .databind ()
method from your codebehind. / P>
To see something like this in your page_load method Required:
Protected Zero Page_load (Object Sender, EventArgues E) {lnkMyLink.DataBind ();}
Only this thing to be kept in mind That is to use data binding for something like this, that is, data is not binding, in the future, it may be a bit confusing for anyone who maintains your code. Although it will be very fast and easy to determine what you have done And why did you do this work, Anything that causes confusion in the future should be removed from your code, wherever it is correct. Therefore, the following will have to choose a better option in your Page_Load
:
lnkMyLink.NavigateUrl = string.Format ("http://absoluteURL.org?param). = {0} ", session [" Mymapmeter Wheel "]);
Comments
Post a Comment