Click here to Skip to main content
15,891,942 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Display alert message from Code behind in asp.net with parameter passing
Posted
Updated 12-Jun-12 19:31pm
v2

I think the following CodeProject articles
AJAX Enabled MessageBox[^]
Simple MessageBox functionality in ASP.NET[^]
Server Side MessageBox[^]

may be helpful for the above purpose.
 
Share this answer
 
Comments
Usf1095 13-Jun-12 1:36am    
i need JavaScript
Manas Bhardwaj 21-Jun-12 3:17am    
correct +5
VJ Reddy 21-Jun-12 3:41am    
Thank you, Manas :)
This tip contains exactly what you need.

A Windows Form like MessageBox for ASP.NET Website[^]
 
Share this answer
 
You Can use the below method to show the alert message


C#
public static void ShowAlertMessage (String error)
{
 Page page =HttpContext.Current.Handler as Page;
 if(page!=null)
  {
 error=error.Replace("'","\'");
 ScriptManager.RegisterStartupScript(page, page.GetType(),"err_msg","alert('"+error+"');",true);
  }

}
 
Share this answer
 
v2
 
Share this answer
 
Hi,

you can use attractive alert message for your asp.net application. see below links,

jQuery Dialog[^]

jQuery Dialog in c#[^]


hope it will solve your purpose.

thanks
-Amit
 
Share this answer
 
This is a normal way of calling a JavaScript method.Hope this helps.

C#
this.ClientScript.RegisterStartupScript(this.GetType(), "Some Title", "<script language=\"javaScript\">" + "alert('Detailed Message Goes Here!');" + "window.location.href='WebForm2.aspx';" + "<" + "/script>");
 
Share this answer
 
v2
Comments
Usf1095 13-Jun-12 2:24am    
i have some conditions pass in JavaScript
I agree with Mr Mohan's answer using ScriptManager.RegisterStartupScript is the right practice in C#
Try this too..,



C#
public static void display(string Somemessage)
{
string abc =TextBox1.Text; /*assume that textbox1 holds the parameter you want to pass*/

   string script = "<script type=\"text/javascript\">alert('" + abc + "');</script>";

   //check if page already has executed any alert before
   Page page = HttpContext.Current.CurrentHandler as Page;


   if (page != null && !page.ClientScript.IsClientScriptBlockRegistered("alert"))
   {
      page.ClientScript.RegisterClientScriptBlock(typeof(Alert), "alert", script);
   }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900