Set ASP.Net Hyperlink NavigateUrl QueryString parameter using C# and VB.Net

Last Reply 8 months ago By pandeyism

Posted 8 months ago

hello,

i have hyper link and one textbox

i want to assign textbox value to hyperlink - nagivateurl as query string like 

navigateurl="~/url.aspx?ID="+ textbox1.text

please advice

Posted 8 months ago

Hi nauna,

Please refer below sample.

HTML

ID:
<asp:TextBox runat="server" ID="txtValue" />
<asp:Button ID="Button1" Text="Assign" runat="server" OnClick="Assign" />
<asp:HyperLink ID="hlURL" runat="server" Text="View" />

Code

C#

protected void Assign(object sender, EventArgs e)
{
    hlURL.NavigateUrl = "Default.aspx?ID=" + txtValue.Text;
}

VB.Net

Protected Sub Assign(ByVal sender As Object, ByVal e As EventArgs)
    hlURL.NavigateUrl = "Default.aspx?ID=" & txtValue.Text
End Sub

Screenshot