英语翻译Now when thePageRequestManager is informed of an error,i

问题描述:

英语翻译
Now when thePageRequestManager is informed of an error,it will redirect the browser toErrorPage.aspx.It also adds an aspxerrorpath query string argument to the URLthat indicates the URL of the page where the problem originated,as shown here:
You can writecode in ErrorPage.aspx that reads the aspxerrorpath information.For example,you might include a Retry button that redirects the user to the originalrequested page,like this:
string url = Request.QueryString["aspxerrorpath"];
if (url = null) Response.Redirect(url);
If your websiteuses custom error pages but you don’t want them to apply to asynchronouspostbacks,you must set the ScriptManager.AllowCustomErrorsRedirect property tofalse.
In complexpages,you might have more than one UpdatePanel.In this case,when oneUpdatePanel triggers an update,all the UpdatePanel regions will be refreshed.
However,if youhave more than one UpdatePanel and each one is completely self-contained,thisisn’t necessary.In this situation,you can configure the panels to updatethemselves independently.Simply change the UpdatePanel.UpdateMode propertyfrom Always to Conditional.Now the UpdatePanel will refresh itself only if anevent occurs in one of the controls in that UpdatePanel.
To try this out,create a page that has several UpdatePanel controls,each with itsbutton.Thenadd code that places the current time in the label of all three controls:
protected voidPage_Load(object sender,EventArgs e)
{ lblTime1.Text = DateTime.Now.ToLongTimeString();
lblTime2.Text =DateTime.Now.ToLongTimeString();
lblTime3.Text =DateTime.Now.ToLongTimeString();}
When you clickone of the Refresh Time buttons,only the label in that panel will be updated.The other panels will remain untouched.
1个回答 分类:综合 2014-11-21

问题解答:

我来补答
简单意译了一下:
当有错误通知到PageRequestManager的时候,它会重定向到ErrorPage.aspx页面.并将产生错误的URL附加到该页面的QueryString中的aspxErrorPath参数.类似这样:
http://localhost/Ajax/ErrorPage.aspx?aspxerrorpath=/Ajax/UpdatePanels.aspx
你可以在ErrorPage.aspx中编码来读取aspxErrorPath信息.比如你可以包含一个Retry按钮来让用户重试之前的页面.
string url = Request.QueryString["aspxerrorpath"];
if (url ! = null) Response.Redirect(url);
如果你的网站自定义了错误页面但是你不希望其应用到异步提交(比如ajax).你可以设置ScriptManager.AllowCustomErrorsRedirect属性为false.
在比较复杂的页面,你可能包含多个UpdatePanel.在这种情况下,当其中一个UpdatePanel触发的时候,所有的UpdatePanel都会被刷新.
所以当你有多个UpdatePanel,而且每一个都是完全自包含的(就是并没有嵌套,这很重要).这时候,你需要将每个Panel设置为独立刷新的.只需要设置UpdatePanel.UpdateMode属性从Always改为Conditional.这样,UpdatePanel内的控件触发的刷新就只刷新自己了.
试一下这种情况,创建一个页面包含多个UpdatePanel,每个都包含自己的按钮.添加以下代码,刷新当前时间到相关的Label.
{代码段}
当你按下按钮,只有相应的UpdatePanel会被更新,其他的保持不变.
 
 
展开全文阅读
剩余:2000
上一页:减术分裂
下一页:语文学习与巩固