Displaying Alert Message Boxes from your .aspx page

Step 1 : Create a General class and place the following Code in it

public static void CreateMessageAlert(System.Web.UI.Page senderPage,
string alertMsg, string alertKey)
{
ScriptManager.RegisterStartupScript(senderPage, senderPage.GetType(), alertKey, “alert(‘” + alertMsg + “‘);”,true);
}

Step 2 : Call the created method from where ever you wish to send the alert from


string alertmessage = “Thank You for visiting DotNetSpider.com”;

YourClassName.CreateMessageAlert(this,alertmessage,”alertKey”);

Where YourClassName is nothing but the name of the class file where your
CreateMessageAlert method resides and alertmessage is where you assign the
string you wish to display.

About these ads

Strip Non Numeric Values from a string

/// <summary>

/// this function strips non-numeric values out of a string and returns the numeric content of a string.

/// </summary>

/// <param name=”Value”></param>

/// <returns></returns>

public static string StripNonNumeric(string Value)

{

return System.Text.RegularExpressions.Regex.Replace(Value, “\\D”, “”);

}