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.

0 件のコメント:

コメントを投稿