Using system;
Using system. Collections. Generic;
Using system. text;
Using system. IO;
Using system. Web;
Using system. Web. UI;
Using system. xml;
Using system. drawing;
Using system. configuration;
Using system. Web. UI. webcontrols;
Using system. Text. regularexpressions;
Using system. Security. cryptography;
Namespace classlibrary
{
# Region string control class
/// <Summary>
/// String control class
/// </Summary>
Public static class controlstring
{
# Region message function
# region display prompt message
///
// display prompt message
///
/ // data to be displayed
// page class
Public static void showmessagebox (string str_message, page)
{< br> type cstype = page. getType ();
clientscriptmanager cs = page. clientscript;
CS. registerstartupscript (cstype, "", "alert ('" + str_message + "');", true);
}
# Endregion
# Region display the message and direct it to the target page
/// <Summary>
/// Display the message and direct it to the target page
/// </Summary>
/// <Param name = "str_message"> display data </param>
/// <Param name = "url"> target path </param>
/// <Param name = "page"> page class </param>
Public static void showmessageboxredirect (string str_message, string URL, page)
{
Type cstype = page. GetType ();
Clientscriptmanager cs = page. clientscript;
CS. registerstartupscript (cstype, "", "alert ('" + str_message + "'); window. Location. href = '" + URL + "';", true );
}
# Endregion
# Region display and close this window
/// <Summary>
/// Display information and close this window
/// </Summary>
/// <Param name = "str_message"> display data </param>
/// <Param name = "page"> page class </param>
Public static void showmessageboxandclosewindow (string str_message, page)
{
Type cstype = page. GetType ();
Clientscriptmanager cs = page. clientscript;
CS. registerstartupscript (cstype, "", "alert ('" + str_message + "'); window. Close ();", true );
}
# Endregion
# Region display information window and move back
/// <Summary>
/// Display the information window and move back
/// </Summary>
/// <Param name = "str_message"> display data </param>
/// <Param name = "page"> page class </param>
Public static void showmessageboxgoback (string str_message, page)
{
Type cstype = page. GetType ();
Clientscriptmanager cs = page. clientscript;
CS. registerstartupscript (cstype, "", "alert ('" + str_message + "'); window. History. Go (-1);", true );
}
# Endregion
# Endregion
# Region get length Function
# Region obtain a string of the specified length
/// <Summary>
/// Obtain the specified length string
/// </Summary>
/// <Param name = "str"> raw data </param>
/// <Param name = "count"> obtain the length </param>
/// <Returns> return data </returns>
Public static string getlimitstr (string STR, int count)
{
If (Str. length> count)
STR = Str. substring (0, count );
Return STR;
}
# Endregion
# Region obtain the first n strings
/// <Summary>
/// Obtain the first n strings
/// </Summary>
/// <Param name = "str"> raw data </param>
/// <Param name = "N"> specify the length </param>
/// <Returns> return data </returns>
Public static string getnstring (string STR, int N)
{
Int INTN = N;
If (INTN <1) {INTN = 1 ;}
String tmpstr = STR;
Char [] cc = tmpstr. tochararray ();
Int intlen = tmpstr. length;
Int I;
For (I = 0; I <cc. length; I ++)
{
If (system. convert. toint32 (CC [I])> 255 | (system. convert. toint32 (CC [I])> 64 & system. convert. toint32 (CC [I]) <91 ))
{
Intlen ++;
}
}
If (intlen> N)
{
Tmpstr = tmpstr. substring (0, tmpstr. Length-1 );
Tmpstr = getnstring (tmpstr, INTN );
}
Return tmpstr;
}
# Endregion
# Endregion
}
# Endregion
}