1. Use JavaScript, CTRL + enter to send messages
[Code] & lt; script language = "JavaScript" & gt;
Function document. onkeydown ()
...{
VaR E = event. srcelement;
If (event. keycode = 13 & event. ctrlkey = 1)
...{
Document. getelementbyid ("linkbutton1"). Click ();
Return false;
}
}
2. Apply the accesskey of the Web button control property, ALT + A to send messages (it is better to press Ctrl + enter)
You only need to set the value to a in the accesskey of the Web button control property.
Some tips commonly used in Asp.net
Warning window
///
/// The alert dialog box is displayed on the server.
///
/// Message, for example, "cannot be blank! "
/// Page class
Public void alert (string str_message, page)
...{
Page. registerstartupscript ("", "& lt; & #83 characters> alert (" "+ str_message +" "); alert (" "+ str_message +" "); document. forms (0 ). "+ str_ctl_name + ". focus (); document. forms (0 ). "+ str_ctl_name + ". select (); If (confirm ("" + str_message + "") = true) {document. forms (0 ). "+ Btn + ". click ();} If (confirm ("" + str_message + "") = true) {document. forms (0 ). "+ btn_redirect_flow + ". click ();} else {document. forms (0 ). "+ btn_redirect_self + ". click ();} document. forms (0 ). "+ str_ctl_name + ". focus (); document. forms (0 ). "+ str_ctl_name +" .select({;toptop.doc ument. location. href = "" + URL + ""; <br & gt; & lt;/script & gt; [/Code] ");
}
}
Determines whether it is a number.
///
/// Name: isnumberic
/// Function: determines whether the input is a number.
/// Parameter: String otext: Source Text
/// Return value: bool true: false: No
///
Public bool isnumberic (string otext)
...{
Try
...{
Int var1 = convert. toint32 (otext );
Return true;
}
Catch
...{
Return false;
}
}
Obtain the actual length of a string (including Chinese characters)
// Obtain the actual length of the string ostring
Public int stringlength (string ostring)
...{
Byte [] strarray = system. Text. encoding. Default. getbytes (ostring );
Int res = strarray. length;
Return res;
}
Convert carriage return to Tab
// When you press enter on a control with a keydown event, it becomes a tab.
Public void tab (system. Web. UI. webcontrols. webcontrol)
...{
Webcontrol. Attributes. Add ("onkeydown", "If (event. keycode = 13) event. keycode = 9 ");
}
If the index is exceeded during the deletion in the DataGrid page
Public void jumppage (system. Web. UI. webcontrols. DataGrid DG)
...{
Int int_pageless; // defines the number of page jumps
// If the current page is the last page
If (DG. currentpageindex = DG. The PageCount-1)
...{
// If there is only one page
If (DG. currentpageindex = 0)
...{
// After deletion, the page is displayed on the current page.
DG. currentpageindex = DG. The PageCount-1;
}
Else
...{
// If the last page contains only one record
If (DG. Items. Count % DG. pagesize = 1) | DG. pagesize = 1)
...{
// After deleting the last record of the last page, the page should jump to the previous page
Int_pageless = 2;
}
Else // if the number of records on the last page is greater than 1, the records are still on the current page after the last page is deleted.
...{
Int_pageless = 1;
}
DG. currentpageindex = DG. pagecount-int_pageless;
}
}
}