2012年3月28日水曜日

Respons.Redirect problem in UpdatePanel

I want to reload my page in respone to click of that is placed in UpdatePanel.

I used Response.Redirecrt(Request.URI.ToString()) , i want to reload my page for loading new user control into UpdatePanel in page load event mean that i only want to refresh update panel area by restarting page lifecycle.

but ASPAJAX respond with a response stream error.

what's the problem? and what can i do?

You can not useResponse.Writein Ajax framework because there is no?whole?page postback to?take?place.If you want to display some text in a web page,you can place a asp:Label in a web form and display a text in the Label.
Wish this can help you.
?
Response.Redirect can work in Ajax framework. Try to use asynchronous post back? through the trigger in asp:UpdatePanel. Here are some sample codes for your reference.
<div>
<asp:UpdatePanel ID="upnl" runat="server">
<ContentTemplate>
<asp:Button ID="btnRedirect" runat="server" Text="Redirect" OnClick="btnRedirect_Click" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnRedirect" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div
Behind Code:
protected void btnRedirect_Click(object sender, EventArgs e)
{
????Response.Redirect("Default.aspx");
}
Wish this can help you.

You mean that i can't redirect to a new page in page postback and also i can't force current page lifecycle repeatation.


ooh my problem is complicated, my page redirect by a button that this button is placed in a usercontrol that this UC load dynamicaly.

mean when i wriet code fro updatepanel , i don't know about what is the name of button and button change in ech postback because UC change in each postback.


I have download new version of AJAX RC version and Response.redirect is working for me...


No,I don't mean you can not redirect to a new page in page postback in current web page lifecycle repeatation.If you have some operations similar to Response.Write,you?can?not?do?it?in?Ajax?framework?as?that in ASP.NET?2.0.If?you?load?a?user?control?dynamically?and?redirect?to?a?new?web?page,
it?should?work?in?Ajax?package.Can?you?post?some?codes?here?with?the?response?stream?error??This?will?help?us?to?fix?the?problem.
The codes I provided in my last post can work fine in framework through asynchronous post back in a asp:UpdatePanel.

Thanks jasoon for your help.

Error is:

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

Details: Error parsing near ' <!DocTYPE HTML PUB'.

and code is link this:

i didn't useResponse.Write()orResponse.Write()and aslo my didn;t set anywhere traceing to true i only used some HttpModules in my projects.

but when ic call to Response.Redirect("") in server in button_Click of button , this error occur.

what is my fault.


Thanks jasoon for your help.

Error is:

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

Details: Error parsing near ' <!DocTYPE HTML PUB'.

and code is like this:

http://forums.asp.net/thread/1508052.aspx

I didn't useResponse.Write()or response filters and aslo i didn't set trace to true anywhere , i only used some HttpModules in my projects.

but when i call to Response.Redirect("") in server in Click of button , this error occur.

i describing again that this button placed in an UpdatePanel (with default settings) and cuase UpdatePanel to refresh.

what is my fault?


I tried to place a asp:Button in the asp:UpdatePanel of a user control and redirect to a new web page.It worked fine.Do you try my codes in my earlier post? Does it work in your PC? Try to download the latest Ajax package from this website and check if it works - http://ajax.asp.net/default.aspx?tabid=47&subtabid=471
Try to check your web.config if it is the same as the following.(Ajax RC 1.0 web.config)
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
Wish this can help you.

Thanks a lot jasson.

Your help be completely and the best.

My fault be incorrect configuring the web.config , i ignore addingScriptModuleHTTPModule.

Best regards.


oh my god!

my previous problem is solved but new problem appear:

if i use Server.Transfer in place of Server.Response same error appear in my IE window.

what's the problem?


Hi, Does you mean that you can redirect to a new page in the same window.

I am now facing an annoying problem. The redirect can do inside updatepanel, but it will open a new window for each redirect. I expect that a new page can be loaded in the same window.

Could you pleas help me.

I had a post to describe the problem.

http://forums.asp.net/p/1134773/1809506.aspx#1809506


Hi, Does you mean that you can redirect to a new page in the same window.

I am now facing an annoying problem. The redirect can do inside updatepanel, but it will open a new window for each redirect. I expect that a new page can be loaded in the same window.

Could you pleas help me.

I had a post to describe the problem.

http://forums.asp.net/p/1134773/1809506.aspx#1809506

0 件のコメント:

コメントを投稿