ASP. NET shows the result case on the second response

Source: Internet
Author: User

Description:

Requirements will beTextboxThe value of the value entered in the "Forward" clause is the same as that in the "Forward" clause.Label.

PlaneDefaultUpper Control

Widget

Namespace

Label

Lblvalue

Textbox

Txtvalue

Button

Buttonsubmit


PlaneResultpageUpper Control

Widget

Namespace

Label

Lblresult

Method 1:

1.1On the planeResultpageOfPage_loadIn the method, add the delimiter generation:

  Protected   Void Page_load ( Object Sender, eventargs E)
{
Try
{
String Sresult = (Textbox) previouspage. findcontrol ( " Txtvalue " ). Text;
Labelresult. Text = Sresult;
}
Catch (Exception ex)
{
Throw Ex;
}
}

1.2InDefault. aspxPrecedingButtonsubmitPressPostbackurlAttribute settingsResultpageHidden area.

1.3Now you can see the result.

1.4Description:

1.4.1 , previouspage
attributes:

Asp. net Cross-page sending in the webpage , by default, Asp. net buttons and other controls that cause sending back on the webpage submit the page back to the page itself. In some cases, you may need to send a page to another page. page class exposes a name
previouspage attributes. If the source and target pages are in the same Asp. net application Program , previouspage attributes include references to the Source Page.

1.4.2 , button the control has a new sensitivity postbackurl . attribute is get or set, click button URL .

1.4.3,PostbackurlThe value after the property is set to"~ /Resultpage. aspx","~ /"In the same region.

1.4.4,Page. findcontrolMethodYes

Method 2:(Previouspage)

2.1InSolution exploerSelect usWebSolution.WebsitE | add folder | app_code folder.

2.2Use website | add new item | class in the app_code File Repository to add a C # file named registrationinformation. CS.Add the following generation:

  Private   String Svalue;
Public   String Value
{
Get { Return Svalue ;}
Set {Svalue = Value ;}
}

2.3Add the Public License registrationinforamtion to defalult. aspx. CS:

///   <Summary>
/// Registrationinformation type, only regionality
///   </Summary>
Public Registrationinformation
{
Get
{
Registrationinformation ri =   New Registrationinformation ();
Ri. Value = Txtvalue. text;
Return Ri;
}
}

2.4InDefault. aspxPrecedingButtonsubmitPressPostbackurlAttribute settingsResultpageHidden area.

2.5Previouspagetype command under the page command of the result. aspx File

<%@ Previouspagetype virtualpath="~ /Default. aspx" %>

2.6
Resultpage_aspxIn page_load (), the token is as follows:

code highlighting produced by actipro codehighlighter (freeware)
http://www.CodeHighlighter.com/

--> try
{
registrationinformation RI = previouspage. registrationinformation;
Ri. value;
}< br> catch (exception ex)
{

ThrowEx;
}

2.7After renewal is completed, you can view the result.

2.8Description:

2.8.1 We are Result. aspx File Page Add" <% @ Previouspagetype Virtualpath= "~ /Default. aspx" %> " Previouspagetype The directive can Load " Previouspage. registrationinformation; "

2.8.2 previouspagetype

@ PreviouspagetypeProvides a method to obtain the strong type of the previous page.PreviouspageAttribute access Previous Page. ItsAttributeInclude:TypenameAndVirtualpath

Typename: Specifies the type name of the previous page.

Virtualpath:Specifies the path to generate a strongly typed file.

 

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.