Skip to content
Loading
How to create messagebox on server side in asp.net ?
  • its not working ....can you plz give me a demo..plz
    +1
  • Jayakumar Balasubramaniam
    Definitely, you can.
    +2
  • Can i use it in else {}  part ??
    +1
  • Jayakumar Balasubramaniam
    Hi Krutika,
     
    If you are just going to display some content in message box, please use below code snippet which will work for sure.
     
    1. public void MessageBox(string message)  
    2.         {  
    3.             HttpContext.Current.Response.Write("alert('" + message + "');");  
    4.         }  
    *Please accept if this helps you. 
    +1
  • Thank you sir....bt i am getting how to use that property...can you plz explain me
    +1
  • Jayakumar Balasubramaniam
    Hi Krutika,
     
    In ASP.net we do have an option called RegisterClientScriptBlock.Using this from server side you can add a script to the page which will run instantly.
     
    So, you can insert the "alert('some text')" from server side in your else part which will be displayed in page.
     
    Please refer below url for more info. 
     
    https://forums.asp.net/t/1273098.aspx?how+to+use+Page+RegisterClientScriptBlock+
     
    https://stackoverflow.com/questions/1905716/clientscript-registerclientscriptblock
     
    https://msdn.microsoft.com/en-us/library/bahh2fef(v=vs.110).aspx
     
    *Please accept this answer if it helps you. 
    +1
  • Hi
     
    You can refer folowing url 
     
    https://www.codeproject.com/Articles/11684/Server-Side-MessageBox
     
    http://www.4guysfromrolla.com/articles/021104-1.aspx 
    +1