Click here to Skip to main content
15,445,427 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
I want to redirect a page to this URL:

C#
Response.Redirect("StudentMedical.aspx?sid=" + StudentID);


This is C# code:

I want to implement the same code on click of using jQuery
Posted
Updated 2-Feb-22 5:29am
v3

First, store your StudentID as a public variable in C#:

In client-side, use this:

JavaScript
var url = "http://StudentMedical.aspx?sid=" + <%= StudentID %>;

JavaScript
$(location).attr('href',url);
 
Share this answer
 
v3
You can do any of the below methods:

C#
// HTTP redirect
window.location.replace("http://yourdomian.com");

// like clicking on a link
window.location.href = "http://yourdomian.com";

//or
var url = "http://yourdomian.com";    
$(location).attr('href',url);
 
Share this answer
 
v2
Comments
m-shraddha 11-Aug-14 1:56am    
I want to also pass querystring as shown in above code
You can use :)
JavaScript
var nextUrl = location.protocol + "//" + location.host + "/yourpage.aspx"?mappInfo=" + queryStringValue;
window.open(nextFormUrl, '_self');
 
Share this answer
 
try this in jquery function:-

C#
var url = "yourpage.aspx";
$(location).attr('href',url);
 
Share this answer
 
Refer this link

jquery-redirect-to-another-page[^]

Hope it will help you
 
Share this answer
 
Comments
m-shraddha 11-Aug-14 1:41am    
I saw the solution in above page. But it was just helpful to redirect page to the specified url. But i want to pass query string as well in url as I have mentioned in the question. So it wont help me to redirect the page. Hence thanks for help

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