In ASP. NET, you often need to use scripts to reconcile the values passed between pages. The following is a simple example of scriptcallback and server. Transfer.Code
Webform1.aspx
Add the _ dopostback script to the head. If the page contains buttons such as hyperlink, the script and two hidden controls "_ eventtarget" and "_ eventargument" are automatically generated by the framework, manually add
<Form ID = "form1" method = "Post" runat = "server">
<Input type = "hidden" name = "_ eventtarget">
<Input type = "hidden" name = "_ eventargument">
<A href = "javascript :__ dopostback ('scriptcallback', 'scriptcallback')"> scriptcallback </a>
<Asp: textbox id = "textbox1" style = "Z-INDEX: 101; left: pixel PX; position: absolute; top: 152px" runat = "server"> sometext </ASP: textbox>
C #
Webform1.aspx. CS
Private void page_load (Object sender, system. eventargs E)
{
If (ispostback)
If (request. Form ["_ eventargument"] = "scriptcallback ")
Server. Transfer ("webform2.aspx", true); // The second parameter indicates whether the form and querrystring values of the page are retained.
}
Webform2.aspx. CS
Private void page_load (Object sender, system. eventargs E)
{
If (this. Context. Handler! = Sender)
Response. Write (request. Form ["textbox1"]);
}
VB. NET
Webform1.aspx. VB
Private sub page_load (byval sender as system. Object, byval e as system. eventargs) handles mybase. Load
If ispostback then
If request. Form ("_ eventargument") = "scriptcallback" then
Server. Transfer ("webform2.aspx", true) 'Second parameter indicates whether to retain the form and querrystring values of the page
End if
End if
End sub
Webform2.aspx. VB
Private sub page_load (byval sender as system. Object, byval e as system. eventargs) handles mybase. Load
If not me. Context. handler is sender then
Response. Write (request. Form ("textbox1 "))
End if
End sub