473,320 Members | 2,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

display messagebox in asp.net using c#

24
hi
i want to diaplay a messagebox in asp.net..how can i do this.. can anyone suggest me a code in c#..can i use the alert function..if so whats the code..i even want the ok and cancel button on the msgbox..kindly suggest me the code for this..

thank you
Aug 28 '07 #1
3 1986
mzmishra
390 Expert 256MB
Three steps u need to do
1 create a function(this will be .cs file)
public static void ExecuteScript(Page webpage_, string script_)
{
StringBuilder scriptBuilder = new StringBuilder( @"<script language=JavaScript>");
scriptBuilder.Append(script_);
scriptBuilder.Append(@"</script>");
JavaScriptUtil.RegisterScript(webpage_, "2", scriptBuilder.ToString());
webpage_.Response.Write(scriptBuilder.ToString());

}
2.call this function(this will be .cs file)
ExecuteScript(this.Page, "Confirmfunction('Your Message');");

3. Create a function "Confirmfunction" in your aspx file


function Confirmfunction(msg)
{
var confirmationvalue = confirm(msg);


if (confirmationvalue == true)
{
//then do something
}
}
Aug 28 '07 #2
Vijey
3
hi
i want to diaplay a messagebox in asp.net..how can i do this.. can anyone suggest me a code in c#..can i use the alert function..if so whats the code..i even want the ok and cancel button on the msgbox..kindly suggest me the code for this..

thank you
This is very easy in javascript:
Go to source/Html page (in .aspx) and write this function.

<script type="text/javascript">
function ConfirmMsg()
{
if( confirm('Are you sure?') )
{
return true;
}
else
{
return false;
}
}
</script>

Note: "confirm" must be in lower caption.

call this function in Button OnClientClick:

OnClientClick="return ConfirmMsg()"

Another way also we can write it directly in the button OnClientClick:
OnClientClick="return confirm('Are you Sure?')"
Aug 29 '07 #3
Shashi Sadasivan
1,435 Expert 1GB
you will need to use javascripts.
Please do not use the MessageBox class as it is a part of the windows.forms framework.
Unless you are using it purely for debugging. (its a quick thing to use for debugging on a standalone machine)
Aug 29 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Wally | last post by:
I am trying to display images from an Access 2000 database and I get an error "Invalid Parameter Used" when I execute the code line "picBLOB.Image = Image.FromStream(stmBLOBData)" in my Visual...
1
by: Kevin R | last post by:
I'm running the HelloWorldForm example from Microsoft to learn how to use ..net. I'm using Microsoft Visual Studio .NET 2003, 1.1 framework. I run the HelloWorldForm example. The example runs...
7
by: jez123456 | last post by:
Hi, I have the following method where I need to display which database is being processed, however, the label lblDatabase dosn't seem to work until the end. private void...
18
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those...
1
by: Kevin R | last post by:
I'm running the HelloWorldForm example from Microsoft to learn how to use ..net. I'm using Microsoft Visual Studio .NET 2003, 1.1 framework. I run the HelloWorldForm example. The example runs...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.