By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 890 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 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
function:
lblResult.Text = Request.Form("ReturnValue")
2. Switch to html view and copy the following from <html>
tag to </html> tag:
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft
Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual
Basic .NET 7.1">
<meta name="vs_defaultClientScript"
content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<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;
}
</Script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post"
runat="server">
&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"
runat="server"
Width="199px"></asp:Label>
<INPUT style="Z-INDEX: 103; LEFT:
88px; WIDTH: 269px; POSITION: absolute; TOP: 164px;
HEIGHT: 32px"
type="submit"
onclick="AskQuestion();" value="Submit">
</form>
</body>
</HTML>

3. Run it and click the button.

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

HTH,

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.