Request. urlreferrer. absoluteuri;
Obtain the absolute path of the last request URL of the client)
For example:
Protected Void Page_load ( Object Sender, eventargs E)
{
If ( ! Ispostback)
{
Hyperlink1.navigateurl = Request. urlreferrer. absoluteuri;
}
}
Maintainscrollpositiononpostback = "true"
Gets or sets a value that indicates whether the user is returned to the same location in the browser on the client after sending the message back.
For example: <% @ Page Language = " C # " Autoeventwireup = " True " Codefile = " Default. aspx. CS " Maintainscrollpositiononpostback = " True " Title = "" Inherits = " Test_default " %>
Defaultbutton = "submitbutton"
Set the default from button
For example:<FormID= "Form1"
Defaultbutton= "Submitbutton"
Defaultfocus= "Textbox1"
Runat= "Server">
Postbackurl = "~ /Test/search. aspx"
Set submission page
For example:
Default. aspx: < Form ID = "Form1" Runat = "Server" Defaultbutton = "Submitbutton" Defaultfocus = "Searchterm" >
< ASP: textbox ID = "Searchterm" Runat = "Server" > </ ASP: textbox > < BR />
< ASP: button ID = "Button2" Runat = "Server" Text = "Submitbutton" Postbackurl = "~ /Test/search. aspx" /> < BR />
</ Form >
Search. CS: Protected Void Page_load ( Object Sender, eventargs E)
{
If ( ! Ispostback)
{
Textbox searchterm = New Textbox ();
Searchterm = (Textbox) page. previouspage. findcontrol ( " Searchterm " );
Response. Write (searchterm. Text );
}
}
Usesubmitbehavior:
Specify Button The control uses the client browser's submission mechanism or ASP. NET Sending back. By default, the value of this attribute is True , Resulting in Button Controls use the browser's submission mechanism. If False , Then ASP. NET Page framework adds client scripts to the page to send the form to the server.
When Usesubmitbehavior The property is False Control developers can use Getpostbackeventreference Method to return Button . Getpostbackeventreference The string returned by the method contains the text of the client function call, which can be inserted to the client for event processing.Program.
Instance: prevents multiple button submissions
< ASP: button ID = "Btnsumbit" Runat = "Server" Usesubmitbehavior = "False"
Onclientclick = "This. value = 'sumbit '; this. Disabled = true ;" Text = "Sumbit" Onclick = "Btnsumbit_click"
/>
Protected Void Btnsumbit_click ( Object Sender, eventargs E)
{
System. Threading. thread. Sleep ( 3000 );
Response. Write (datetime. Now. tostring ());
}
Onclientclick:
Obtains or sets the client script executed when a click event of a server control is triggered.
Example: Add a confirmation prompt to the delete column of the gridview. < ASP: gridview ID = " Gridview1 " Runat = " Server " Autogeneratecolumns = " False " >
< Columns >
< ASP: boundfield datafield = " Field name " Headertext = " Name " />
< ASP: templatefield showheader = " False " >
< Itemtemplate >
< ASP: linkbutton ID = " Linkbutton1 " Runat = " Server " Causesvalidation = " False "
Onclientclick = ' <% # "Return confirm (\" are you sure you want to delete "+ eval (" field name ") +? \ ");" %> '
Commandname = " Delete " Text = " Delete " > </ ASP: linkbutton >
</ Itemtemplate >
</ ASP: templatefield >
</ Columns >
</ ASP: gridview >