Problem description:
After Ajax (using Microsoft's updatepanel), the export function is incorrect. Because the export function uses response to directly output the content, and Ajax's asynchronous method cannot resolve this cause an error.
Solution Process:
I found it online, can I use this http://forums.microsoft.com/china/ShowPost.aspx? Postid = 2732578 & siteid = 15. However, if your button is created dynamically or in the template, the POST method cannot solve the problem. Although the content in this section does not solve my problem, it gives me a thought. Since Ajax cannot be used for requests, PostBack is used.
Solution:
1. added the onclientclick event to the original export button.
Btnexport. onclientclick = "Return autoform_export ('postbackeventtarget _ isexport ');";
2. added the JavaScript function autoform_export to the client.
Function autoform_export (postbackeventtarget)
{
Webform_dopostbackwitexceptions (New webform_postbackoptions (postbackeventtarget, "", true, "", "", false, true ));
Return false;
}
3. The server determines whether the event is an export event based on request ["_ eventtarget. Note the notes in red below
If (page. request ["_ eventtarget"]! = NULL)
{
Bool isinasyncpostback = false;
Scriptmanager Sm = scriptmanager. getcurrent (PAGE );
If (SM! = NULL)
{
Isinasyncpostback = Sm. isinasyncpostback;
}
If (isinasyncpostback)
{
/*
Make sure to determine whether axaj is used for asynchronous requests. Otherwise, after you click the export button, other Ajax requests, page. request ["_ eventtarget"] retains the original value, which leads to incorrect judgment.
*/
_ Isexport = false
}
Else
{
String postbackeventtarget = page. request ["_ eventtarget"]. tostring ();
If (postbackeventtarget = "postbackeventtarget_isexport ")
{
_ Isexport = true;
}
Else
_ Isexport = false;
}
}
Else
_ Isexport = false;
}
Others:
No other methods have been found. If you have any better methods, please kindly advise!