/** // <Summary>
/// Make the control focus
/// </Summary>
/// <Param name = "str_ctl_name"> obtain the focus Control ID value, for example, txt_name </param>
/// <Param name = "page"> page class </param>
Public void getfocus (string str_ctl_name, page)
{
Page. registerstartupscript ("", "<SCRIPT> document. forms (0 ). "+ str_ctl_name + ". focus (); document. forms (0 ). "+ str_ctl_name + ". select (); </SCRIPT> ");
}
40. The subform returns the primary form.
/** // <Summary>
/// Name: Redirect
/// Function: The subform returns the primary form.
/// Parameter: URL
/// Return value: NULL
/// </Summary>
Public void redirect (string URL, page)
{
If (session ["ifdefault"]! = (Object) "default ")
{
Page. registerstartupscript ("", "<SCRIPT> Publish topics .doc ument. Location. href = '" + URL + "'; </SCRIPT> ");
}
}
41. Determine if it is a number
/** // <Summary>
/// Name: isnumberic
/// Function: determines whether the input is a number.
/// Parameter: String otext: Source Text
/// Return value: bool true: false: No
/// </Summary>
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;
}
42. Convert the carriage return to the 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 ");
}
43. If the index is exceeded when the page is deleted in the DataGrid
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;
}
}
}