Postbackurl attribute in Asp.net

Source: Internet
Author: User

 

Traditional Approach

To facilitate the comparison, I would like to spend one minute reviewing the old method of transferring data on the webpage.An HTML table element has an action attribute.It is used to specify the resources on the server (the so-called resources refer to a webpage, a script, a program, etc.) to process the submitted data. The following code is an example.

 

<HTML>
<Head> <title> sample HTML form

<Body>

<Form name = "frmsample" method = "Post"Action= "Target_url">

<Input type = "text" name = "fullname" id = "fullname"/>

<Input type = "button" name = "Submit" value = "Submit"/>

 

The value entered in the text field (fullname) will be submitted to the page or program specified by the Action attribute of the form element. For ASP. NET developers, even if they have used standard HTML forms, they are rare.

 

ASP. NET developers face the task of transferring data information from one webpage to another. They include session variables, cookies, querystring variables, caching, and even the server. Transfer Method. However, ASP. NET 2.0 also provides another option.

 

Another solution provided by ASP. NET 2.0

When designing ASP. NET 2.0, microsoft realized the need to cross-pass data between webpages. With this awareness, a postbackurl attribute is added to the button control of ASP. NET. It allows you to specify the path to which the form and the above data are sent when the user submits the form (that is, determined by the URL value specified by the postbackurl attribute ). In general, cross-page transfer is a process in which the client uses JavaScript For transmission in the background.

 

Use previous page

When an ASP. NET page is loaded through a cross-page shipping call, the ispostback attribute of the object above it will not be triggered. However, there is a property called previouspage (Previous Page) that allows you to access and use cross-page shipping pages of those applications.

When a cross-page request occurs, the previouspage attribute of the current page stores the reference of the push and delivery page. If the page is not triggered by cross-page delivery, or the page is in a different program group, the previouspage attribute will not be initialized.

 

 

Let's look at an example:

 

Questionwrite. aspx

<Asp: dropdownlist id = "drplesson" runat = "server" Height = "22px" width = "140px">
</ASP: dropdownlist>

<Asp: imagebutton id = "imagebutton1" imageurl = "~ /Images/next2.gif "runat =" server"
Postbackurl = "~ /Teacher/questionanswer. aspx"/>

 

Questionanswer. aspx. CS

Dropdownlist d = (dropdownlist) This.Previouspage. Master. findcontrol ("contentplaceholder1"). findcontrol ("drplesson ");

 

The template page is used here, so when using findcontrol, pay attention to the points.

For more information about using findcontrol, see this blog:

Findcontrol-use the findcontrol method for the master page

Http://blog.sina.com.cn/s/blog_67aaf4440100lugx.html

 

Findcontrol-use the findcontrol method on the Content Page

Http://blog.sina.com.cn/s/blog_67aaf4440100luh6.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.