Question

I am trying to call __doPostBack from within JavaScript and then navigate to another page. The script I have is:

$(document).ready(function() {  
   $("a.change-link").click(function(){          
             __doPostBack("","");  
             location.href='pageToGoTo';                                                                                            
   });

});

The code is not getting to the location.href='pageToGoTo' line after the post back.

Is there anyway to achieve this functionality?

Thanks

Was it helpful?

Solution

location.href='pageToGoTo'; will never be executed since you're posting the entire form back to the server. You'll need to redirect the request on the server-side.

Response.Redirect = "pageToGoTo";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top