Asp.net Common Code 5 [reprint]

Source: Internet
Author: User
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 the carriage return button on the control with the keydown event, it becomes the tab.
Public void Tab (System. Web. UI. WebControls. WebControl webcontrol)
{
Webcontrol. Attributes. Add ("onkeydown", "if (event. keyCode = 13) event. keyCode = 9 ");
}

43. If the index public void jumppage (System. Web. UI. WebControls. datagrid dg) is exceeded when the page of the DataGrid is deleted)
{
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;
}
}
}

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.