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

2012年3月28日水曜日

Response.Redirect

This is the code to redirect to a new page from a GridView...

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
string SeqNo = "";
string dd = "";
int ix = GridView1.SelectedIndex;

if (ix >= 0)
{
SeqNo = GridView1.SelectedRow.Cells[4].Text;
dd = GridView1.SelectedRow.Cells[1].Text;
if ( (SeqNo.Trim() != "") && (dd.Trim() != "") )
Response.Redirect(String.Format("DocketOnline.aspx?DocketDate={0}&SeqNo={1}&cn={2}", dd, SeqNo, FCaseNo));
}
}

Prior to placing the GridView in an UpdatePanel, the code above worked fine. Now clicking on the Select column, triggering the code above, gives the error:

Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500

How do I fix this?

All I want is to have GridView in an UpdatePanel so that paging is AJAXed...I also want the user to be able to select a command column to go to another page.

Thanks,

Jay

You would either have to:

1. on the RowDataBound register javascript to open a new window for the selected row event...

or

2. Just use a link button and set the url and targetpane properties in a column to open a new window or to navigate to the new page.

or - cancel the asynchpost prior to the redirect and then redirect (not sure this one will work though)...

Using the response.rediect in asynch the ScriptManger gets involved and things just get messy...because it intercepts everything and the response.redirect messes up the expected structure it is figuring on sending to the client for the partial page update..


Hi,

I have a user control which does not have script manager. In this user controll I input zipcode and it will populate the city state. This user control in on the main page along with other user controls. Script manager is on the main page. There is no script manager proxy. When I click on the button to populate the city state info it is populating it but whole page is refreshed instead of city and state which is inside the update panal. Does anyone have any idea whats causing this issue?

Regards,
Nepalaya


Response.Redirect should work fine during an async postback.

Response.Redirect

I have a button on updatePanel, wich has event handler and Response.Redirect in it.

It's not working.

Haw can i resolve this problem.

Thansk

Deykin:

I have a button on updatePanel, wich has event handler and Response.Redirect in it.

It's not working.

Haw can i resolve this problem.

Thansk

Updatepanel and response.redirect don't work together and they shouldn't either. If you are going to redirect the page to some where else then why even bother to use updatepanel on it for. Updatepanel's purpose is to do partial postback on the same page. Hope that helps.


Actually, Response.Redirect() is supposed to work just fine during async postbacks.

Make sure that you have the ScriptModule registered in your application's web.config file. If it's not, check out the web.config that got installled to your Program Files ASP.NET AJAX folder to see what it should look like.

Thanks,

Eilon


As I recall, someone had the same problem a while ago. It never worked unless ajax implemented it in its lastest version.

Hi

instead of using Response.Redirect try this:

ScriptManager.RegisterClientScriptBlock( lbEditDocument,typeof(LinkButton ),"TestBlock","window.open('"+ redirectUrl +"', '_top');",true );

HTH


I'm with Luis on this one. Response.Redirect has been working fine for me with the RC, and if there's some bug, I'd love to find out before RTM gets out the door.

We could use some more info here, like what exactly is happening when the button is clicked. (I guess it's not doing the redirect, but is it refreshing the page? Is it doing an async postback? What does the traffic look like when you use Fiddler or Nikhil's Web Development Helper?)

Response.Redirect - issues...

Alrighty...so I can't get response.redirect to work anymore. I found another post with a solution, but that doesn't do anything except give me javascript errors.

The given solution is to change Response.Redirect("page.aspx") into something like this:

string script ="window.location.href='" + page +"';";

Page.ClientScript.RegisterStartupScript(this.GetType(),"redirect", script,true);

When I try to do this I just get the ubiquotous "object required" javascript error. I need to be able to redirect my users...any ways to do this when using Atlas?

David

I should note that if you set your scriptmanager to

EnablePartialRendering="false"

Then response.redirect works just fine. Since I don't know much about that attribute I have set it to false for now and am still moving forward.

However, if anyone knows how to get around it when it is set to true, I would love to hear it.

Thanks,

David


I can't say for sure how to fix your redirect problem, but I know that setting the EnablePartialRendering attribute to "false" is the wrong way. This allows you page to be dynamically updated... the entire foundation AJAX programming.

hello.

well, i'm really not sure on what you're talking about.

ajax extensions do respect response.redirect and you do get a redirect in the client (of course, this means that you'll get a complete refresh on the client side).

Response.Redirect + Ajax ;location.href too do the same

I have to rediraect to the same page by adding a connection string

ie

'Response.Redirect("Aju.aspx?SplashFrom=0")

but i know that Response.Redirect is not Ajax compatible

So i have done the code like bellow

Protected Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

ScriptManager.RegisterStartupScript(UpdatePanel1, Me.GetType(), "redirectMe", "location.href='Aju.aspx?SplashFrom=0';", True)

End Sub

But this code also refreshes the whole page

what can i do to only update the update panel by doing a redirection?

NOTE:Button2 is inside the same update panel so i did not and ant trigger in update panel


Response.Redirect works just fine with Ajax. If you are getting errors when using it, then most likely your web.config is not set up correctly. Response.Write is not compatible with partial-page updates, but that is for totally different reasons.

Now, for what you're trying to do: Even if you use Response.Write, you are going to get a full page refresh because you are navigating to a new page. Any time you load a new page (even if you just change the querystring parameters, you are still loading a new version of the page), you are going to get a full refresh. Only when you are changing the contents of a page, such as the value of controls, can you do partial-page updates.


In that scenario, you probably shouldn't be trying to use a redirect at all (client side or server). If you need to update another UpdatePanel from Button2_Click, you could either make Button2 one of its AsyncPostbackTriggers or you could call UpdatePanel1.Update() in Button2_Click.

If that's not helpful, provide a bit more detail about what you're trying to do.


See you are redirecting to other page, So definately you can get a full refresh page.

If you change any content then it will possible to stop refresh the page


chetan.sarode:

See you are redirecting to other page, So definately you can get a full refresh page.

No, i am redirecting to same page with change in query string


As far as the client (browser) is concerned, that is a new page. It has to reload the page.


gt1329a:

In that scenario, you probably shouldn't be trying to use a redirect at all (client side or server). If you need to update another UpdatePanel from Button2_Click, you could either make Button2 one of its AsyncPostbackTriggers or you could call UpdatePanel1.Update() in Button2_Click.

If that's not helpful, provide a bit more detail about what you're trying to do.

No;my button is inside the one and only one update panel i have.

I am redirecting to the SAME page with change in query string,because i have programed to fetch data from database based on the value in query string .

If i give the value in query string it will become easy to book mark the exact page


Please listen.

Itdoes not matter that you are redirecting to the same page. Any change in the URI will cause the browser to load what it considers to be a different page. It is a new request to the server. It is still a redirect. The page will be reloaded and you will see a visible refresh... no matter what you have in updatepanels... no matter if not a single thing changed on the page. That is how it works.

If I redirect fromhttp://www.mysite.com/mypage.aspx?q=1 tohttp://www.mysite.com/mypage.aspx?q=2, even if I the content does not change and I do nothing with the querystring, it will still cause a refresh.

If you want to use the querystring parameters to allow you to bookmark specific state of the page, that's fine. Just understand that you will have a visible refresh.


To create bookmarkable URLs, use document.hash instead of document.href. This manipulates the anchor of the URL, which you can do without causing a refresh.


could you please show me an example of document.hash

Thanks in advance


I have a similar problem. I cannot Response.Redirect("newpage.aspx") or ScriptManager.RegisterStartupScript(Me.UpdatePanel1, Me.GetType(), "redirectMe", "location.href='newpage.aspx';", True) with a button inside updatepanel. Is there anyway around this?
Please help!

Response.Redirect and AsyncPostBackTrigger

I've got a "Previous" button on a webform that uses this code to take user to previous page:

Response.Redirect(Session.Item("PREVIOUSPAGE"))

I set the button as an AsyncPostBackTrigger. This error occurs when the button is clicked:

Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.

If I change the button from AsyncPostBackTrigger to PostBackTrigger, it works fine.

Why won't this button work asynchronously? I've got 2 other buttons on the same page that are being used as AsyncPostBackTriggers with no issue.


I think it would not work because asynchronously - the Ajax enviroment is just expecting to work with the session variables of the current page, but you are trying to tell it to revert back to previous session ids with a redirect. A postback will work because it reloads or mimics a back button of the browser. Not saying it is not possible - I am wrong plenty of times - but it would make sense that that would be the behavior. You'll also get the same behavior if a session times out and the user tries to do a back button to a previous ajax enabled page.

What I would at least consider a better solution is leverage the ability with Ajax to load and unload controls dynamically. This way you can have 'paging' and still retain the benefits of the asyncrhonous enviroment.


There is an article on how to achieve that in the Scott Guthrie's blog:


http://weblogs.asp.net/scottgu/archive/2007/02/06/asp-net-ajax-goodies-documentation-download-back-button-support-new-animation-control.aspx

Juan

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 doesnt work with UpdatePanel in Beta 1

I have a page with an update panel that contains a few buttons that need to be able to redirect to another page. The script manager is located on a master page.

Every time one of those buttons are clicked, i get one of two errors:

    If the button is inside of a gridview, i get this error:
    Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.
    If the button is NOT inside of a gridview, i get this error:
    Sys.WebForms.PageRequestManagerParserErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 302

Here's a test aspx page that I set up:

1<%@dotnet.itags.org. Page Language="VB" title="Untitled Page" MasterPageFile="~/main.master" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %>2<%@dotnet.itags.org. Register Assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="Microsoft.Web.UI" TagPrefix="ajax" %>3<asp:Content ID="Content1" ContentPlaceHolderID="plhContent" Runat="Server">4 <ajax:UpdatePanel runat="server">5 <ContentTemplate>6 <asp:Label runat="server" ID="lblTime" /><br />7 <asp:Button runat="server" ID="btnRefresh" Text="Refresh" /><br />8 <asp:Button runat="server" ID="btnRedirect" Text="Redirect" /><br />9 <asp:LinkButton runat="server" ID="lnkRedirect" Text="ASP Linkbutton" /><br />10 <a href="http://www.google.com/" title="test redirect">HTML Hyperlink</a>11 </ContentTemplate>12 </ajax:UpdatePanel>13</asp:Content>
And here's the codebehind:
1PartialClass test2Inherits System.Web.UI.Page34Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.Load5 lbltime.Text = now()6End Sub78 Protected Sub btnRedirect_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles btnRedirect.Click9 Response.Redirect("http://www.google.com/",True)10End Sub1112 Protected Sub btnRefresh_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles btnRefresh.Click13 lblTime.Text = Now()14End Sub1516 Protected Sub lnkRedirect_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles lnkRedirect.Click17 Response.Redirect("http://www.google.com/",True)18End Sub19End Class


The LinkButton causes the same error, so it's not just limited to the button control. It looks like it affect anything that posts back to the server and causes a redirect.

Thanks for any help you can give me!

We found this out today too. The fix is to pass a location.href back to user.

ScriptManager.RegisterStartupScript(pnlYourUpdatePanel,this.GetType(),"redirectMe","location.href='blah.aspx';",true);

Sorry it is in C#... Hope this helps.


hello.

i've just built a sample project with the following code:

master page:

<%@. Master Language="VB" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<script runat="server"
</script
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:scriptmanager runat="server" ID="manager" />
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>

page:

<%@. Page Language="VB" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %>
<script runat="Server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
lblTime.Text = Now()
End Sub

Protected Sub btnRedirect_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRedirect.Click
Response.Redirect("http://www.google.com/", True)
End Sub

Protected Sub btnRefresh_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRefresh.Click
lblTime.Text = Now()
End Sub

Protected Sub lnkRedirect_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkRedirect.Click
Response.Redirect("http://www.google.com/", True)
End Sub
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:updatePanel runat="server" id="panel">
<contenttemplate>
<asp:Label runat="server" ID="lblTime" /><br />
<asp:Button runat="server" ID="btnRefresh" Text="Refresh" /><br />
<asp:Button runat="server" ID="btnRedirect" Text="Redirect" /><br />
<asp:LinkButton runat="server" ID="lnkRedirect" Text="ASP Linkbutton" /><br />
<a href="http://links.10026.com/?link=http://www.google.com/" title="test redirect">HTML Hyperlink</a>
</contenttemplate>
</asp:updatePanel>
</asp:Content
everything is working here with the beta extensions. are you sure you've set up web.config correctly?


Luis,

When looking at the XMLHttpResponse google.com is being returned which is causing the parser error. Not sure how you are getting this to work with the Beta release?? Also, not sure how config would cause this?

Matt


hello.

well just recalled one problem i've seen before where the users updated the prefix but left it pointing to the old ctp dll which was still in the bin folder and it just blow everything apart. btw, here's what i'm getting back from the server side in response to a click over the redirect button (2nd one from the top):


22|pageRedirect||http://www.google.com/|


Luis Abreu:

everything is working here with the beta extensions. are you sure you've set up web.config correctly?

I think I do. I have a Microsoft.Web.Extensions assembly in the web.config. Is there aything else I need?

1<compilation debug="true" strict="false" explicit="true">2 <assemblies>3 <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>4 <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>5 <add assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>6 </assemblies>7</compilation>


Luis Abreu:

well just recalled one problem i've seen before where the users updated the prefix but left it pointing to the old ctp dll which was still in the bin folder and it just blow everything apart.

I did delete the old CTP DLL, and added the new assembly registration to the top of the page:

1<%@. Register Assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="Microsoft.Web.UI" TagPrefix="ajax" %>2

hello again.

can you confirm the response you're getting back from the server? is it similar to the one i've shown before?


How do I access the server response information?

hello.

use fiddler. if you're using ie, you must create a site in IIS and then use the name of the machine (http://machinename/site). if you're using firefox, configure it so that it uses a local proxy (127.0.0.1 port 8888 if i'm not mistaken).


It is definitely in the config. Again... good call Luis... you are missing these values in your config and this should cure the problem.

<httpModules><add name="WebResourceCompression" type="Microsoft.Web.Handlers.WebResourceCompressionModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><add name="ScriptModule" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></httpModules>
Thank Luis for that one. =)
P.S. That is under httpHandlers

That worked! You guys are awesome.


Thanks!


Thanks - Guys!

I was experiencing the same problem in Beta 2, which this solution apparently resolved that issue.


Hi Guys!

I Got the Same error in my current project. I cant redirect to another page from inside the UpdatePanel. Finally I saw this forum and got a wonder result and answer. Its really amazing and thanks a lot for u all guys..

rgds,

Senthil

Response.Redirect doesnt work with AJAX Extensions Beta 1 (Atlas)

I was using the July Atlas CTP and I decided to give the new AJAX Extensions beta a try... now anytime I call Response.Redirect() when I handle an event for a control that is inside an UpdatePanel I get an error that says, "Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed." This happens regardless of whether I'm doing a partial postback or a regular postback as long as the control that caused the event is inside an UpdatePanel.

I found it odd that ScriptManager.IsInAsyncPostBack == true when I clicked a button that wasn't assigned to an AsyncPostBackTrigger... I'm assuming that that probably has something to do with why the Response.Redirect() didn't work. (Yes, I did verify that UpdatePanel.UpdateMode was set to Conditional.)

This is all fine with me I guess as long as there's another way to redirect to another page in server side code. Anyone know what I need to do?

Thanks,
Jon

Calling Response.Redirect() during an async post is supported. Make sure you have the ScriptModule on web.config for this work:

- Federico

  
 <httpModules> <add name="ScriptModule" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </httpModules>

Right after I posted the original message I noticed that I had put the <httpModules> stuff in the wrong place. :)

Response.Redirect doesnt work when the button is inside an ajax updatepanel

Hello,

I am getting the following error whenever I click a button inside an ajax updatepanel and it tries to Response.Redirect from the code behind.

Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes 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 P'

I wasn't sure if it was my page not being correct or if it was something else. So I created two basic test pages test.aspx and test2.aspx. I click a button on text.aspx and it is supose to redirect to test2.aspx. This is a basic example giving the exact same error. So hopefully if I can get a resolution to this I could fix my real asp.net page. Thanks, Risso

Here is the test.aspx code:

<%

@dotnet.itags.org.PageLanguage="C#"AutoEventWireup="true"CodeFile="test.aspx.cs"Inherits="test" %>

<%

@dotnet.itags.org.RegisterAssembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"Namespace="System.Web.UI"TagPrefix="asp" %>

<!

DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

htmlxmlns="http://www.w3.org/1999/xhtml">

<

headrunat="server"><linkhref="css/modaldialog.css"rel="stylesheet"type="text/css"/><title>Untitled Page</title>

</

head>

<

body><formid="form1"runat="server"><div><asp:ScriptManagerID="ScriptManager1"runat="server" ></asp:ScriptManager><asp:UpdatePanelID="UpdatePanel1"runat="server"><ContentTemplate><asp:ButtonID="Button1"runat="server"OnClick="Button1_Click2"Text="Button"/></ContentTemplate></asp:UpdatePanel></div></form>

</

body>

</

html>

HERE IS the Code behind code:

using

System;

using

System.Data;

using

System.Configuration;

using

System.Collections;

using

System.Web;

using

System.Web.Security;

using

System.Web.UI;

using

System.Web.UI.WebControls;

using

System.Web.UI.WebControls.WebParts;

using

System.Web.UI.HtmlControls;

public

partialclasstest : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

}

protectedvoid Button1_Click2(object sender,EventArgs e)

{

Response.Redirect(

"~/test2.aspx");

}

}

HI.

Try to useServer.Transfer.


I did server.transfer shown below. It still gives the same error message. I put a breakpoint in the test2.aspx to see if it makes it to that pages_load event and it does, but the browser throws the exact same error message as listed in the first post. Any other ideas?

protectedvoid Button1_Click2(object sender,EventArgs e)

{

Server.Transfer("~/test2.aspx");

}


Hi, u must knwo that Response.Redirect and Server.Transfer work inside UpdatePanel.

can u share us the detail of the error that u have.


I tried your code and one of my own and it appears to be fine. Before you start beatin your head against the wall, try this...

This a must read from Eilon Lipton's Technical blog on Microsoft ASP.NET and ASP.NET AJAX when trying to solve PageRequestManagerParserErrorException errors!

http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx?CommentPosted=true#commentmessage A


Eilon Lipton's tips are great, I just add some more: Test "test2.aspx" for any invalid html markup, also test the response with fiddler.

Ok,

I found out were it is happening, but now I am not sure how to solve it since what I have to remove is also needed. I found that it was inside the web.config. I'm adding 2 httphandlers that were needed to fix other AJAX issues. I don't recall exactly what those issues were because this is a big application and it was a while back. I do remember these were needed to fix other ajax problems though. I do not want to remove these and have them break other ajax controls/tools. Anyone know a work around for this. I do know now that these httpHandlers are what is causing my Response.Redirect() issue in my updatepanel.

I removed the following lines from my web.config for it to work.

<

httpHandlers>

<

removeverb="*"path="*.asmx"/>

<

addverb="*"path="*.asmx"validate="false"type="Microsoft.Web.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<

addverb="GET,HEAD"path="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"validate="false"/>

</

httpHandlers>

Risso


Shoot, I just realized those were needed for the Ajax to work in IE. And by me removing those lines from the web.config it just does a normal postback and not an asynchronous call. That is why it worked for me. So really nothing has changed. I am back to nothing on why the response.redirect() doesn't work. You guys mentioned that you took the code and were able to get the response.redirect() to work. I'm not sure what in my environment could be any different. I'm running this off of localhost and I do not have IIS running.

Yeah. Have you tried a new website as ajax supported web? I tried both an iis and casini version of the test. What version of vs are you running?


Aesop:

Yeah. Have you tried a new website as ajax supported web? I tried both an iis and casini version of the test. What version of vs are you running?

Agree, use vs to create a new "ASP.NET Ajax-Enabled Web Site" or "ASP.NET Ajax CTP-Enabled Web Site", and use the web.config of the new site as a template, so carefully migrateyourweb.config into the template.

You can get a template web.config also from a similar path:

C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025

C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Futures January CTP\v1.0.61025


Yes, I got it to work!! Thank you for your persistent responses. I did what you both recommended and started a new Ajax Application and pulled its web.config to compare to mine and went line by line with testing each line and found what I was missing. My web.config didn't have

<

httpModules>

<

addname="ScriptModule"type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

</

httpModules>

Risso


Hi Rissoman,

Thanks your post. I have the problem like you. I took 2 days to find why I always take the PageRequestManagerParserErrorException. Well, I am upgrading the website, and missing the <httpModules>

Thanks again,

HUH


Thanks to everyone who posted about this. You've just saved me a lot of time and effort! Thanks!


HI,

Thanks a ton .for that code..

regards

Delia Joe

Response.Redirect from UpdatePanel causes full refresh

I noticed that when I redirect to another page from within an update panel, the page fully refreshes (may be that's by design?).

How can I prevent this from happening?

Thanks.

you can not prevent this, this is the way any web sites works. When you say response.redirect, you are instructing the browser to make a fresh call to particular aspx page.


rmaiya:

you can not prevent this, this is the way any web sites works. When you say response.redirect, you are instructing the browser to make a fresh call to particular aspx page.

that is right.

If you are trying to only update the panel then try something like, updatePanel1.update();, or if you want to load a new page inside the panel try putting an iframe inside the panel


What is considered as best practice?

For example, if you click on the above links (such as "Learn", "Downloads", "Ajax"...) on this page, how do they ensure that that the header and footer elements of the page don't "blink"?


As they are different pages, I do want to do a response.redirect to keep the URL's friendly, but at the same time, I would like my header and other static elements not refresh each time. Do they use partial page caching to achieve this?

Response.Redirect in AJAX

I have a button in Update panel.

On button click I have written

Response.Redirect("InterMediateMsg.aspx", False)

When I executes the application I got the Error..

Sys.WebForms.PageRequestParserErrorException:The message received from the server could not be parsed.

How should I implement Redirection in AJAX.

Hi,

in the onclick (client side!!) you just place self.location.href='urltogoto'. Don't use AJAX for something like that but plain old javascript.

Grz, Kris.


Response.Redirect should work fine during an async postback. Try dropping the "False"... I'm not sure if you can use that option.


Actually I have performed server side coding( Database operations) on button click .

After the successful operation I want to navigate to another page.

How could I do it.


I have tried it by dropping false.

Actually this second parameter specifies whether I want to terminate execution of current page or not.

Is there any effect of browser.

I am using IE 6.0


Make sure that you have buffer set to false on the page from which you wish to redirect - otherwise output will already have been streamed out to the client, and things will go horribly wrong!

This cost me quite a bit of investigation a while ago..!


i think this error may be because it is trying to process a redirect within the update panel. assuming you use a trigger for the updatepanel and button, set it to a asp:PostBackTrigger instead of a asp:AsyncPostBackTrigger, this will send your page into a full postback, which may solve your problem (i haven't tested it).


I try the way you suggest, and its work !Wink


glad to help!Smile


Thnx ChrisCicc ,

It's working.

I have set the Trigger for button to PostBack and it worked.

Response.Redirect in a PostBack causes javascript error => workaround here

There's a problem in Atlas when calling a Response.Redirect on a postback (and the ScriptManager uses "EnablePartialRendering=true"). E.g. doing a Response.Redirect("otherpage.aspx") from the button-click event code.

There's a workaround, however.

Instead of doing:

Response.Redirect("otherpage.aspx");

do this:

Page.ClientScript.RegisterStartupScript(
this.GetType(), "redirect",
"window.location.href='otherpage.aspx';",true);

I wrote a custom httpmodule (acquirerequeststate event) that needed to do a response.redirect in certain cases. This threw the "unknown error" on atlas pages. I added "false" for the endReponse parameter and it works fine now. Response.Redirect("page.aspx",false).

thanks

Response.Redirect in Asp.net AJAX

Hi All,

I Developed a project in as.net with Asp.net Ajax... i used Response.Redirect several time in my web project with and without script manager... and its worked fine...
but some tells me...this is not recommended to use Response.Redirect in asp.net AJAX....and when i will deploy on Production server... there may be chance of some error.............

So please give your opinon....
Thanks
SajjadPerhaps you are confusing this with Server.Transfer. There should be no issues with Response.Redirect.
R u 100% sure...
and what issue with Server.Transfer....

REsponse.Redirec will not cause any issues if you invoke it from CodeBehind pages.

I have worked with one developer who instantiated the Page object, and tried to use the page object.REsponse.REdirect() and that failed - as it should.


Response.Redirect not working in RC version

I am trying to use Response.Redirect in the RC version of AJAX but it is returning an error. I have found a similar post to this issue and it discusses Beta2 vs RC references. I have ensured that all of my references are pointing to the System.Web.Extensions for the RC release yet the problem still exists.

Any ideas as to how I can fix this issue? Sorry if this is repeated, I just didn't find a clear response in the other posts.

But, what's the error? Can you post it?

The error is:

Sys.WebForms.PageRequestManagerParserException: The message received from the server could not be parsed... Error parsing near '<!DOCTYPE html PUB'

My code basically performs a Response.Redirect to another page in the site when a certain condition is met. I am using the AJAX Update Panel and various button control triggers that are all working fine.


You can't place Redirect in partial postback.

PageRequestManagerParserException waits for data from UpdatePanels (for example in JSON format, but I'm not sure), but you Redirect gives another data. In you case it like that redirect doing at server and PageRequestManagerParserException gets new page.

You must do redirect with some javascripts.

You have 2 ways:

1) use my evalscripts.js (it extends UpdatePanels, that it can evaluate javascripts, so you can put window.open('xxxyyy.aspx','_top') in some Literal in Label, and it works)

2) use ScriptManager.RegisterClientScript static method. On this forum is very many messages about it. Try to search. (and yes, you also do it throught javascript's window.open)

And of course try to read documentation. Maybe something changed in RC1 and there are some new methods for redirect. I don't know.


Something at you end is not set up well. Check this to make sure everything checks uphttp://ajax.alpascual.com/Walkthrough/AtlasToAspNetAjax.aspx

jriell:

Thanks for the feedback. Where can I obtain your evalscripts.js?

You can download all this from http://ajax.asp.net


Thanks for the feedback. Where can I obtain your evalscripts.js?

Thank You.

As a followup on the problem I had. I did omit something from the web.config of my site. After adding this element to the web.config, the Response.Redirect code that I have started working. It seems as though this functionality does work in the RC version at least.


jriell:

Thank You.

As a followup on the problem I had. I did omit something from the web.config of my site. After adding this element to the web.config, the Response.Redirect code that I have started working. It seems as though this functionality does work in the RC version at least.

Can you say what you add to web.config? Just interesting.

ps. this is work in RC1 ?


albertpascual:

jriell:

Thanks for the feedback. Where can I obtain your evalscripts.js?

You can download all this from http://ajax.asp.net

this is my own script, and there are now way to obtain it from ajax.asp.net , it can be found athttp://forums.asp.net/thread/1465522.aspx

Response.Redirect without Postback

Hi,

I am new to Ajax. can any one tel me .

is it possible to redirect to another page with out postbacking?

if it is possible will u please tel me the steps to do redirect without postbacking.

Its posible through certain control which has postback url or navigate url as its property.

Have a look into these controls

<asp:LinkButtonID="LinkButton1"PostBackUrl="~/T1.aspx"runat="server">LinkButton</asp:LinkButton><asp:ButtonID="Button1"PostBackUrl="~/t1.aspx"runat="server"Text="Button"/><asp:HyperLinkID="HyperLink1"NavigateUrl="~/T1.aspx"runat="server">HyperLink</asp:HyperLink>

Hope this will help


A postback is bound to take place as you would be loading a new page, so it is not possible at the first place.
However there is trick which you can use for a better user experience, mind you it would not avoid the postback but it would not cause any flicker in your screen. You can place these two tags at the head of your HTML dcocument..

<META http-equiv="Page-Enter" content="blendTrans(Duration=0.2)">
<META http-equiv="Page-Exit" content="blendTrans(Duration=0.2)">

You can also refer to the following link for the pros and cons of this...
http://secretgeek.net/fajax.asp

Hope this could be of some use to you
Cheers
Ritesh


This tag

<META http-equiv="Page-Enter" content="blendTrans(Duration=0.2)">
<META http-equiv="Page-Exit" content="blendTrans(Duration=0.2)">

working perfectly...


One thing you guys have missed out.

If the question is correct the above two solutions are wrong.

The question is postback should not happen.

Try this scenario

Have a Button and linkbutton. In the link button set the navigateurl to some file and in button click set respone.redirect to some page.

Now place the meta tag mentioned above.

have a line break in page load. Check which control makes the navigation without postback.

Even if you place the meta tag postback will happen in button click.


and also the following will work for only ie not for other browsers

<META http-equiv="Page-Enter" content="blendTrans(Duration=0.2)">
<META http-equiv="Page-Exit" content="blendTrans(Duration=0.2)">