Click here to Skip to main content
15,905,785 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to pass query string value on clicking any hyperlink which are dnamically generated. Something like this..

XML
<%
------some code----
 clickedalbum = dt6.Rows[0]["albumid"].ToString();

  %>
      <asp:HyperLink ID="HyperLink1" runat="server" href="attendance1.aspx?albumid=<%#clickedalbum %>" >



The result of above code which i am getting is :
abc.aspx?albumid=%3C%#clickedalbum%20%%3E

desired Result:
abc.aspx?albumid=25
Posted

I think issue because of server control. If server control is not really required try using html control.

<a href='attendance1.htm?albumid=<%=clickedalblum%>'>Test</a>



Thanks
 
Share this answer
 
v2
Comments
arbaaz jalil 2-Apr-13 9:05am    
Worked Like a Charm!! Thanks Mate! :)
Ya sure dear arbaaz jalil.

Visual Studio facilitates us that we can also define c# code within our HTML code.
If you want to bind any variable or runtime data to any control from your inherited class then you can do it using <%# %> tag.

here is some sample code where i am trying to binding QueryString value to a Hyperlink.

See below code.

ASP.NET
<asp:hyperlink id="HyperLink1" navigateurl="<%= Request.QueryString["id"] %>" runat="server" xmlns:asp="#unknown"><![CDATA[<%= Request.QueryString["id"] %>]]></asp:hyperlink>

   <asp:label id="Label1" runat="server" xmlns:asp="#unknown"><![CDATA[<%= Request.QueryString["id"] %>]]></asp:label>

        <asp:label id="Label2" runat="server" xmlns:asp="#unknown"><![CDATA[<%= Request.QueryString["id"] %>]]></asp:label>

    <%= Request.QueryString["id"] %>
 
Share this answer
 
Ya sure dear arbaaz jalil.

Visual Studio facilitates us that we can also define c# code within our HTML code.
If you want to bind any variable or runtime data to any control from your inherited class then you can do it using <%# %> tag.

here is some sample code where i am trying to binding QueryString value to a Hyperlink.

See below code.

<pre lang="HTML"> <asp:HyperLink ID="HyperLink1" NavigateUrl='<%= Request.QueryString["id"] %>' runat="server"><%= Request.QueryString["id"] %></asp:HyperLink>

<asp:Label ID="Label1" runat="server"><%= Request.QueryString["id"] %></asp:Label>

<asp:Label ID="Label2" runat="server"><%= Request.QueryString["id"] %></asp:Label>

<%= Request.QueryString["id"] %></pre>
 
Share this answer
 
v2
Hi Arbaaz,

I think you need to generate the Url before using as href in hyperlink.

clickedalbum = dt6.Rows[0]["albumid"].ToString();
String _url = "attendance.aspx?albumid=" + clickedalbum;

now you can use _url.

Thanks
 
Share this answer
 
Comments
arbaaz jalil 2-Apr-13 8:09am    
still not working
T Pat 2-Apr-13 8:32am    
Have you tried using Session or Viewstate to pass clickedalbum value to markup side?
arbaaz jalil 2-Apr-13 9:06am    
I got it figured out. Thanks for your response. :)
you can use

HTML
<# Request.QueryStrin["yourQueryStringName"].ToString()>
 
Share this answer
 
v2
Comments
arbaaz jalil 2-Apr-13 9:06am    
Can you elaborate?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900