Click here to Skip to main content
15,886,860 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when I click on a link in my web page,it should display a message saying"Do you want to continue".This should be done inside the below function
C#
protected void lnk_click(object sender, EventArgs e)
{

}

can I use MessageBox.Show here. But when I tried using it gave me an error
Posted
Updated 16-Mar-12 0:43am
v3
Comments
Mantu Singh 16-Mar-12 5:23am    
use vbscript or javascript to achieve this ......
ProEnggSoft 16-Mar-12 5:47am    
Edit: pre tag for C# code, code tags added - PES

No.

MessageBox (if you used it) would show on the server, not the client.
To display a message box on the client, you need to use javascript. See here: Adding Client-Side Message Boxes in your ASP.NET Web Pages[^]
 
Share this answer
 
Comments
ProEnggSoft 16-Mar-12 5:48am    
Good link. 5!
Oshtri Deka 16-Mar-12 6:44am    
5.
You can use an Asp.Net button to show a MessageBox like this:-
ASP.NET
<asp:button ID="Button1" runat="server" Text="Confirm" OnClientClick="return confirm('Are you sure you want to continue?');"/> 
 
Share this answer
 
v3
You can also register your javascript from server side as follows:

C#
protected void lnk_click(object sender, EventArgs e)
{

      string javaScript ="<script language=JavaScript>\n" +
                   "confirm('Are you sure you want to continue?');" +
                   "</script>";
      Page.RegisterStartupScript("Confirmation", javaScript);
}
 
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