Search code examples
htmlasp.netparameterswebformshref

adding a parameter to href link


I need to send the user to another webpage but setting up parameters, I am using the QueryString in that page for that. This is my code:

<a href= "school_info.aspx?edit_school=true&school=" + SchoolId>School Profile</a>

SchoolId is a parameter that I need to add, I have tried .ToString() and it does not work, any help?

The parameter is defined in the aspx.cs code


Solution

  • You can do it this way,

    function func(){	
    	var SchoolId  = 0;
    	window.location.href = "school_info.aspx?edit_school=true&school=" + SchoolId;
    }
    <!DOCTYPE html>
    <html>
    <body>
    <a onclick="func();">Click Here</a>
    </body>
    </html>

    That is, calling the href tag from the javascript after manipulating the href link.