Use Ajax in Asp.net to bring up the JS dialog box

Source: Internet
Author: User

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 ~

Related Article

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.