收藏本站 | 论文目录

关键词: python matlab plc 单片机 dsp fpga 仿真 stm32

ASP.NET2.0的跨页回调文献翻译

[关键词:ASP.NET,跨页回调]  [热度 ]
提示:此作品编号wxfy0112,word完整版包含【英文文献,中文翻译

以下仅为该作品极少介绍,详细内容请点击购买完整版!
ASP.NET2.0的跨页回调文献翻译

通信工程文献翻译——在ASP.NET2.0中,跨页提交允许把一个页面的回调回调提交到一个不同的网页中。本文中我们将探索一些不同的跨页提交的方法。

ASP.NET1.1只提供了提交到本页的方式。在很多情况下,我们的解决方案中会有跨页的提交的需求,传统的方法都是通过Response,Redirect或者Server.Transfer的方式转移到另外的一页然后模拟出一个跨页回调的效果。

ASP.NET2.0提供了这种能实现从一个表单页提交到另一个表单页的跨页提交的功能。

如何实现跨页提交

要实现跨页提交,在源表单页里,需要设置控件的PostBackURL这个属性来实现IButtonControl(比如Button,ImageButton,LinkButton)接口来定位到目标表单页。当用户单击这个button控件的时候,表单页就会跨页提交到目标表单页。不需要在源表单页中进行任何设置或编写任何的代码。

通过FindControl方法在目标页中检索源表单页中的信息

目标表单页获得“跨”过来的那一页请求的信息是通过一个不为空的PreviousPage方法。这个属性代表着源表单页并且为源表单页和其控件建立引用。

源表单页上的控件在目标页上可以通过PreviousPage的FindControl方法来获得。

protected void Page_Load(object sender, EventArgs e)

{

    ...

    TextBox txtStartDate = (TextBox) PreviousPage.FindControl("txtStartDate ");

    ...

}

这时目标表单页是不知道源表单页的任何信息的。PreviousPage这个属性的类型是Page,所以检索控件就可以使用FindControl的方法,但开发人员需要对源表单页的结构有一个大体的了解。而使用FindControl方法必然会有一些限制,比如FindControl方法只能依靠开发人员提供的控件的id属性来定位到一个控件。如果源表单页的控件id变了的话那么这个方法就有可能失效。FindControl方法只能处理那些在当前容器里的控件,如果开发人员需要检索在其它控件中(容器)的控件的话,那么首先需要获得其父控件的一个引用。

通过@PreviousPageType指令在目标页中检索源表单页的信息

另外一个方法就是在源表单页已经确定的情况下,使用@PreviousPageType指令。这个指令可以在目标表单页中以强类型的方式访问源表单页。这个指令指定源表单页使用VirtualPath属性还是TypeName属性。PreviousPage属性返回一个强类型的结果来对源表单页进行引用。其允许访问源目标页.......

通过@Reference指令在目标表单页中访问源表单页

第三种以强类型访问源表单页的方法就是在目标表单页中加入@Reference指令到源目标表单页的引用,然后通过再PreviousPage属性来访问源表单页。

通过IsCrossPagePostBack属性来检测跨页的提交

当源表单页跨页提交到目标表单页的时候,目标表单页需要检索源表单页,源表单页就需要在内存中重新加载一次,并且这个过程要经历除了展现(render)以外的所有页面周期所要经过的步骤,而这个被重新加载的页面就是在目标表单页检索源表单页的信息用到的。

源表单页的IsCrossPagePostBack属性指明在目标表单页中使用PerviousPage引用的时候是否重新字内存中被加载。

In ASP.Net 2.0, cross-page post backs allow posting to a different web page, resulting in more intuitive, structured and maintainable code. In this article, we will explore the various options and settings for the cross page postback mechanism.

ASP.Net 1.1 provides for web forms posting back only to themselves. In many situations, the solution requires posting to a different web page. The traditional workaround alternatives were to use Response.Redirect and/or Server.Transfer to move to a different page and simulate cross page post-back behavior.

ASP.Net 2.0 provides a feature known as Cross Page PostBack for a web form to post-back to a different web form (other than itself) 

How to post to a different page

To set a web form to post back to a different web form, in the source web form, set the PostBackURL property of a control that implements IButtonControl (eg. Button, ImageButton, LinkButton) to the target web form. When the user clicks on this button control, the web form is cross-posted to the target web form. No other settings or code is required in the source web form.

Access source page info within the posted page: FindControl Method

The target web form resulting from the cross-page postback provides a non-null PreviousPage property. This property represents the source page and provides reference to the source web form and its controls.

The controls on the source page can be accessed via the FindControl method on the object returned by the PreviousPage property of the target page.

 


以上仅为该作品极少介绍,详细内容请点击购买完整版!


本文献翻译作品由 毕业论文设计参考 [http://www.qflunwen.com] 征集整理——ASP.NET2.0的跨页回调文献翻译!