/ Published in: JavaScript
This can be put into a utility class in your ASP.NET project and put onto the page with ScriptManager.RegisterStartupScript(). The script alters the ASP.NET __VIEWSTATE value which somehow validates requests; if you leave it out the popup wont work.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$(document).ready(function() { //get the current URL var originalUrl = $('form').attr('action'); //change the ASP.NET ViewState value so .NET doesn't break $('#__VIEWSTATE').attr('name', 'name'); //the new URL var url = 'MyPopup.aspx'; //find the form, and change its url $('form').attr('action', url).attr('target', '_blank'); //post the form $('form').submit(); //set it back to the original one $('form').attr('action', originalUrl).removeAttr('target'); //change the ViewState value back to what it was $('#__VIEWSTATE').attr('name', '__VIEWSTATE'); });