Click here to Skip to main content
15,902,634 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hello all,

Pl tell me how to pass the query string thru <a> tag.

The query string value will be in sql server.

ex:
<a href="http://www.com./Sample.aspx?name=">Click here;<a>

the name value should be get from sql server( select query)

Help pl

Regards,
Praveena
Posted
Updated 26-Jul-11 21:21pm
v3

Have a look at the EVAL and BIND methods - http://weblogs.asp.net/leftslipper/archive/2007/06/29/how-asp-net-databinding-deals-with-eval-and-bind-statements.aspx[^]. These could probably be used to achieve the result you are looking for.
 
Share this answer
 
Hi,
Use this

XML
<a href='../Sample/sample.aspx?id=<%#Eval("id") %>'>
                                    <%#Eval("Name") %>
                                </a>
 
Share this answer
 
v3
Use the ASP HyperLink control.

<asp:hyperlink id="lnkMyLink" runat="server" test="Click Here!!" xmlns:asp="#unknown" />


Then, on the Page_Load:

C#
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string query = //Get query string;
lnkMyLink.NavigateUrl = String.Format("http://www.com.Sample.aspx?name={0}", query);
}
}


Should work fine!
 
Share this answer
 
Make it server control by adding ID and runat=server, then onPageLoad use-

C#
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string query = //Get query string from sql server;
linkid.href= "http://www.com.Sample.aspx?name=" + query);
}
}
 
Share this answer
 

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