Use postbackurl and server. Transfer to pass data stickers)

Source: Internet
Author: User

Http://tnt2.cn/blog/article.asp? Id = 108

 

The first is postbackurl. controls such as button and linkbutton all have this attribute. See the following example:

Demo. aspx

Program Code <Asp: hiddenfield id = "hidden_id" runat = "server" value = "test"/>
<Asp: linkbutton id = "linkbutton1" runat = "server" postbackurl = "test. aspx"> linkbutton </ASP: linkbutton>
<Asp: button id = "button1" runat = "server" text = "button" postbackurl = "test. aspx"/>

Test. aspx. CS

Program Code protected void page_load (Object sender, eventargs E)
{
If (previouspage! = NULL)
{
Hiddenfield hidden_id = (hiddenfield) previouspage. findcontrol ("hidden_id ");
If (hidden_id! = NULL)
{
Label1.text = hidden_id.value;
}
}
Else
{
Label1.text = "null ";
}
}

Server. transfer is a server-based method, while postbackurl is client-based. In this sense, cross-page transfer is more convenient than server. Transfer, which improves server performance and reduces processing steps. Apart from this, the two are very similar, but in ASP. NET 2.0, cross-page transfer is obviously a better choice.

If you want to determine whether the page referenced by perviouspage is submitted across pages or transmitted using the server. transfer method, you can determine through the iscrosspagepostback attribute.

Program code if (previouspage! = NULL)
{
If (previouspage. iscrosspagepostback = true)
{
Response. Write ("cross-page post .");
}
}
Else
{
Response. Write ("not a cross-page post .");
}

 
 

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.