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

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日月曜日

Response.redirect causes post back using Atlas


Hi,

I have a webpage with a button on it. The button is placed in an update panel. I want to redirect user to another page when the user press the button. Basically it is a save button which save user information and redirect user to another page.

I tried using response.redirect("anotherpage.aspx") but it caused post back however the button is placed under a n update panel.

Can anyone help me out? I want to save data on button click and redirect user to another page without causing post back.


Thanks.
Imtiaz

Redirect has to cause a postback, you are trying to "redirect" the user.

Firstly, all things inside an update panel cause a postback, they just go through some different steps, and only deal with events in the update panel, and only refresh the part of the page inside the panel.

So your button is designed to postback, which it does... then redirects, the update panel picks this up, and changes the browser page.

The functionality is correct.

If you want, instead of a button with a redirect, make a regular html button with a clientside event.

onclick="redirect();"

function redirect(){

location.herf = 'newURL.aspx';

}

If you call a client side method to change the location of the page, then there is no post back to the server

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.

2012年3月21日水曜日

RoundedcornerExtender in Firefox

I have placed a rounded corner extender inside a datalist. Now I placed a named anchor (<a name="_myanchor">)

In another page I have set a link like "Mypage.aspx#_myanchor"

When its run in IE it works great and page scrolls to the bottom.

When its open in FF it moves to bottom, it takes two secs to draw the rounded corners (my be because there are more than 50 records) and scrolls little up.

I think the reason for this is rounded corner with border is drawn around the actual div resulting in an increase of the size (height also) of the page. When I disabled the extender it works perfect.

Please advice..

Thanks in Advance

Any hope?