By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,250 Members | 1,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,250 IT Pros & Developers. It's quick & easy.

MessageBox in WebForms

P: n/a
You will need to use client side script to display a
message box:

The following code demonstrates the results of the alert
using a hidden input box, and javascript.

Do the following.
1. Create a webform and copy the following into the Load
lblResult.Text = Request.Form("ReturnValue")
2. Switch to html view and copy the following from <html>
tag to </html> tag:
<meta name="GENERATOR" content="Microsoft
Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual
Basic .NET 7.1">
<meta name="vs_defaultClientScript"
<meta name="vs_targetSchema"
<Script language="javascript">
function AskQuestion()
if (confirm('Question
Here')) //Yes clicked if true

document.Form1.ReturnValue.value = "YES";
else // No clicked

document.Form1.ReturnValue.value = "NO";
return true;
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post"
&nbsp; <INPUT name="ReturnValue"
id="ReturnValue" style="Z-INDEX: 101; LEFT: 91px; WIDTH:
206px; POSITION: absolute; TOP: 85px; HEIGHT: 27px"
type="hidden" size="29">
<asp:Label id="lblResult" style="Z-
INDEX: 102; LEFT: 95px; POSITION: absolute; TOP: 51px"
<INPUT style="Z-INDEX: 103; LEFT:
88px; WIDTH: 269px; POSITION: absolute; TOP: 164px;
HEIGHT: 32px"
onclick="AskQuestion();" value="Submit">

3. Run it and click the button.

4. Look at the html to see how it works. It is pretty


Billy Jacobs
-----Original Message-----
How can I get MessageBox in the WebForms?
I would like to display yes/no messagebox and wanted to
capture what value was clicked by the user(i.e., whether
yes or no).

Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.