ラベル request の投稿を表示しています。 すべての投稿を表示
ラベル request の投稿を表示しています。 すべての投稿を表示

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

2012年3月26日月曜日

Retrieve viewstate during a GET request

I have a page with controls that specify a filter on a set ofresults. I have used ajax and the update panel to show updated resultsthrough asynchronous request when the filter gets updated. When theuser selects an item in the set they navigate to a different page...when they then hit the back button they return to the filter page butall the controls are all re-initialized.

What I've been trying isgenerating an id for the page on the initial request (as is done andnormally placed in a hidden field for my custom PageStatePersister thatkeeps the viewstate in a database) but then redirecting the user to aurl with the id appended. So when you later hit the back button youhave the id in the URL.


Next LoadViewState is NOT calledunless the request is the result of a postback. Well I've been tryingto initialize the ViewState in the Page_Load by callingLoadPageStateFromPersistenceMedium() and that does result in callingthrough my custom PageStatePersister... But the ViewState dictionary ofthe page does not get updated... what am I missing?

Or is there another way to accomplish not losing the filter values?

Ok...this is going to be hard for me to explain..but I shall try. And i will suggest two solutions. First of all remember client side styles are not persisted unless asked, and viewstate track changes to state only when tracking is enabled. So all your controls are reinitialised because tracking gets enabled after oninit() and then viewstate just deserializes the stored data.

So unless you set trackviewState(), viewstate is not tracking anything. (Once on, cannot be turned off) Once tracking is on..viewstates items can be marked dirty(IsItemdirty()). You can also set an item to be dirty. Basically tracking allows viewstate to monitor which of its elements have changed since TrackViewState() has been called. Statebag ignores the items that are not marked dirty when it comes to saving view state SaveViewState() and hence items not marked dirty are not serialized.

So one of the solution is to markitems dirty which you want to be persisted before that postback. The other is dont do it by ajax but by actual user controls.

Just a question for you to ponder, if you have two identical pages with a textbox and a button with on onclicking code.

as <as:textbox runat="server" text="abc"><asp:button runat="server" text="submit">

with other pages only having change in its text property as text="the quick brown fox jumps over the little lazy dog" Do the two pages have same viewstate?

Read this article if you want to understand viewstate.

http://msdn2.microsoft.com/en-us/library/ms972976.aspx


I appreciate your feedback but I'm not sure how it applies... I'm not having problems writing viewstate... I'm having problems loading the viewstate during a GET request. I'll try articulating my problem differently:

1) I've persisted the viewstate on the server side.
2) The viewstate is identified by a hidden field and so is in the form data during a postback (this already works)
3) On the first GET of a page I generate the identifier and redirect the request to a page with the viewstate identifier appended to the URL
4) By default Viewstate is NOT loaded during a GET request only POSTBACK
5) On the first GET of the URL+ViewstateID, the viewstate does not exist and the page runs through normal initialization
6) On subsequent requests to URL+ViewstateID does exist and I want to load this Viewstate from storage (see 4)
7) I've tried Page.LoadPageStateFromPersistenceMedium() which does call my pagestatepersister and retrieves the viewstate... now how do I apply this to the page instance...? can I ...?


before you move on to the next page, you can either save your viewstate as I said in my previous post and write it to a session and later on retreive the session, and put it back in viewstate.

Although this can be accomplished by plain sessions.