Iria
Iria

Reputation: 497

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

Upvotes: 2

Views: 81691

Answers (3)

StaPantazis
StaPantazis

Reputation: 41

For anyone looking for it for Razor Pages:

<a asp-route-school="@Model.School" asp-page="/school_info">School Profile</a>

Upvotes: 1

Abdallah Nasser
Abdallah Nasser

Reputation: 41

You Can Use This

<a href="/order/[email protected]">@Model.OrderCode</a>
</p>

So Your parameter should be string , you can convert it to int or something else.

Upvotes: 2

Gowtham Shiva
Gowtham Shiva

Reputation: 3875

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.

Upvotes: 4

Related Questions