2012年3月26日月曜日

Response.Redirect cant worked as expected inside UpdatePanel while placed in a ModalDialog

I placed a updatepanel in a modaldialog and placed a button inside the updatepanel. when clicked on the button, something needs to be done and if necessary, the button maybe call Response.Redirect(...) to force moveing to a new URL in the same Modaldialog.

I placed " <base target='_self' " /> inside the " <head> " of the page, and the Redirect can do as expected while the button is placed outside the updatepanel. but If the button is moved inside updatepanel, the 'Redirect(...)' will always open a new window, that's is unexpected.

I tried the client script, such as ' window.location.replace(...)' also, but it acts as above. even if I placed a <input type='button' onclick='window.location.replace(..)' /> inside the updatepanle.

Is this a bug of UpdatePanel? Because the objective can be done without updatepanel.

Could you please help me?

Thank you very much.

did you try Server.Transfer instead of Response.Redirect ??


Thanks!

I had tried Server.Transfer already yesterday. but a exception is popup.

Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common casuses for this error are when the respons is modified by calls to Response.Write(), response, filters, HttpModules, or server trace is enabled. .....


hi i too faced the same problem i over came it bye writing the Response.Redirect("javascript:mypopfunction()");

in response.redirect write that jave script function call write u r window code in java script to pop up this worked finre for me u also try this it will work if not let me know ao that i may further help u ok byee ALL THE BEST

Vissu


Thank you.

I write client function as follow.

<script>
function MoveToURL(newurl)
{
window.location.replace(newurl);
}
</script>

Then respond to button click event on server-side as follow :

Response.Redirect("javascript:MoveToURL('Dialog2.aspx');");

But the problem still exists. Maybe I didnt catch your real idea. Could you please give a example.


hi pass the page name webform2.aspx as a parameter to function in java script

ieeee....

<script>
function MoveToURL(newurl)
{
var reportWin=window.open(newurl,"options",'resizable=yes,scrollbars=yes,width=780,height=650,left=150,top=50,status=yes')


}
</script>

Then respond to button click event on server-side as follow :

string myaspx="Dialog2.aspx'";

Response.Redirect("javascript:MoveToURL('"+myaspx+"')");

hope this helps...

Vissu


it functions as before. a new window is open unexpected.

it seems all the script executed from inside an updatepanel results in the same. despite of :

window.open

window.location

Response.Redirect


i doing the same thing i send but it is working fine for me i don't know why its not working for u any way try u will defnitly get answer for that ALL THE BEST

Vissu


The problem is that you're trying to do something that requires an HTTP response context to work, in a partial postback which does not return in an HTTP response.

Use something like this:

ScriptManager.RegisterStartupScript(this,this.GetType(),"redir","document.location = 'NewPage.aspx'",true);

hi this will work look at it

ScriptManager.RegisterStartupScript(this,this.GetType(),"EmpReports","javascript:ReportPage('" + PName +"')",true);

write this in C# Code

Vissu


this worked as above. the problem still exists.

Please note that the UpdatePanel is in a ModalDialog.

For the normal window, response.redirect can work correctly.

For the ModalDialog, if updatepanel is not used, the redirect can work correctly by adding <base target='_self' /> to <HEAD>. Once updatepanel is used in modaldialog, the redirect opens always a new window.


Without more much better solution, now I just use the following code:

Replace 'Response.Redirect' with a client script to show a new modal dialog from current dialog.

string script = "window.showModalDialog('Dialog2.aspx'); window.close();";
ScriptManager.RegisterStartupScript(this, this.GetType(), "OpenNewDialog", script, true);

this solution will launch too much dialog window. So I still sincerely hope someone can help me solving this problem ina better way.

Thanks.


You can't do Response.Write() while using an AJAX

See for more details..

http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx


I am using Response.Redirect, not Response.Write, and Response.Redirect can work correctly with an updatepanel inside a normal window. In this case, the new page can be loaded in the same window. Once Used with an updatepanel inside a modal dialog, the new page is loaded always in a newly opened window. The key difference is between normal window and modaldialog.


What you are trying to do is not possible with ModalPopup extender. The ModalPopup usually binds with an Asp Panel renders as Div (Not a Window). So playing with the url Response.Redirect, window.location will always opens a new page.

0 件のコメント:

コメントを投稿