Click here to Skip to main content
16,019,018 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hello sir,
I know to create alert box in server side.
C#
public void Messagebox(string message)
{
        ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + message + "');", true);
}

but how to create message box with ok cancel or yes no options in web application
in server side?

How to create serverside message box with yes or no options in web application?
Posted
Updated 23-Feb-13 3:12am
v2
Comments
Sergey Alexandrovich Kryukov 24-Jan-13 2:36am    
Do you really know what is HTTP and Web? How server-side? Who will look at this message box? A personal on duty in the server factory? Poor guy may decide to quite drinking if he sees it... :-)
—SA
sugunakumaravel 24-Jan-13 3:26am    
Hello Sir, I want to show the message box in client side only.in server side one button click want to check one particular condition after that i want to give message box with yes or no options to the client.Please understand my question clearly and asnwer
[no name] 24-Jan-13 23:52pm    
better use confirm and if proceed based on ok/cancel, in the client script, reload th e page to trigger the page load event,do the stuff there.

1 solution

First write this code in your .ASPX.

XML
<div id="divMessage" runat="server" class="" style="display: none;">
       <asp:Literal runat="server" ID="ltlMessage" Text="test"></asp:Literal>
   </div>



Then just write this code behind you .CS page.

C#
public static void ShowMessage(string _class, string msg, System.Web.UI.HtmlControls.HtmlGenericControl divMessage, Literal ltlMessage)
       {
           divMessage.Style.Add("display", "block");
           divMessage.Attributes.Add("class", _class);
           ltlMessage.Text = msg;
       }



C#
try
               {
                   UISettings.ShowMessage("alert alert-success", "Insert Successfully", divMessage, ltlMessage);
               }
               catch (Exception ex)
               {
                   ShowMessage("alert alert-error", ex.InnerException.Message, divMessage, ltlMessage);
               }
 
Share this answer
 
v2

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