Using system;
Using system. Data;
Using system. configuration;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
Namespace aspnetajaxweb. ajaxuser
{
Public class ajaxusersystem
{
Public ajaxusersystem ()
{
}
/// <Summary>
/// A dialog box is displayed in the ASP. NET environment.
/// </Summary>
/// <Param name = "response"> </param>
/// <Param name = "message"> </param>
Public static void showdialog (httpresponse response, string message)
{
Response. Write ("<SCRIPT> alert (\" "+ message +" \ "); </SCRIPT> ");
}
/// <Summary>
/// A dialog box is displayed in the Ajax environment.
/// </Summary>
/// <Param name = "button"> </param>
/// <Param name = "message"> </param>
Public static void showajaxdialog (Button button, string message)
{
Scriptmanager. registerclientscriptblock (button, typeof (button), button. clientid, message, true );
}
///
Public static void showajaxdialog (page, string message)
{
Scriptmanager. registerclientscriptblock (page, typeof (PAGE), datetime. now. tostring (). replace (":", ""), "alert ('" + message "')", true );
}
/// <Summary>
/// Set the selection item of the list control to a specified item based on the Value Attribute
/// </Summary>
/// <Param name = "list"> </param>
/// <Param name = "value"> </param>
Public static void listselecteditembyvalue (listcontrol list, string value)
{
If (list = NULL) return;
/// The selection item is empty.
If (list. Items. Count <= 0)
{
List. selectedindex =-1;
Return;
}
/// Compare items one by one and set the selection items
For (INT I = 0; I <list. Items. Count; I ++)
{
If (list. items [I]. value = value)
{
List. selectedindex = I;
Return;
}
}
/// No matching items
List. selectedindex =-1;
}
/// <Summary>
/// Set the selection item of the list control to a specified item based on the text property.
/// </Summary>
/// <Param name = "list"> </param>
/// <Param name = "text"> </param>
Public static void listselecteditembytext (listcontrol list, string text)
{
If (list = NULL) return;
/// The selection item is empty.
If (list. Items. Count <= 0)
{
List. selectedindex =-1;
Return;
}
/// Compare items one by one and set the selection items
For (INT I = 0; I <list. Items. Count; I ++)
{
If (list. items [I]. Text = text)
{
List. selectedindex = I;
Return;
}
}
/// No matching items
List. selectedindex =-1;
}
/// <Summary>
/// Create a string by Time
/// </Summary>
/// <Returns> </returns>
Public static string createdatetimestring ()
{
Datetime now = datetime. now;
String dtstring = now. year. tostring ()
+ Now. Month. tostring (). padleft (2, '0 ')
+ Now. Day. tostring (). padleft (2, '0 ')
+ Now. Hour. tostring (). padleft (2, '0 ')
+ Now. Minute. tostring (). padleft (2, '0 ')
+ Now. Second. tostring (). padleft (2, '0 ')
+ Now. millisecond. tostring (). padleft (3, '0 ');
Return (dtstring );
}
}
}
"Seven" happy, all in Sina's new blog version. Come and try it ~~~ Click to enter ~