Gopal Biswas Gopal Biswas - 3 months ago 8
ASP.NET (C#) Question

How to set querystring value using javascript function in ASP.Net?

I have a menu in asp.net page like below:

<ul class="dropdown-menu">
<li>
<a href="employerlist.aspx?id=;javascript:getQueryStringValue('id');">Add Employer</a>
</li>
<li></li>
</ul>


I want to redirect pages to different urls along with a value which returned from the javascript function "getQueryStringValue". Now the problem is I cannot concatenate the url with the javascript function in "href".
Any help will be appreciated.

Answer

Like this:

<a href="" onclick="location.href='employerlist.aspx?id=' + getQueryStringValue('id');return false;">Add Employer</a>