Displaying Message Boxes

P

Paul Johnson

Can a message box be displayed using asp.net code? I know there is a
System.Windows.Forms.MessageBox but i cant use it in my web pages, I always
get an error message saying that Windows cannot be found in System
namespace.
 
C

Captain Chaos

No, The Windows.Forms.MessagesBox (and all other Windows.Forms.*)
are not working under Web.......

Simply use a Clientside JavaScript or VBScript

JavaScript: alert('Hello');
VBScript: Msgbox "Hello"
 
S

Scott M.

Producing a MessageBox by the .NET Framework on an ASP.NET page is an
impossibility because messageboxes are a function of the browser, not the
server.

You need to use traditional client-side script to produce a messagebox in
the browser.
 
K

Kikoz

There is a solution I used in one asp.net application:

In page's html insert hidden field and name it, say,
hidField. Give it attribute runat="server";
in c# (vb) class (code behind) for this page declare this
hidden field like this:

protected System.Web.UI.HtmlControls.HtmlInputHidden
hidField;

Then use its value attribute to give it any message you
need when you need. Say, hidField.Value = "Freaking
message";

Then insert a script function inside of your html,
something like this:

<script>
function checkError()
{
if(document.all.hidField && document.all.hidField.value !
= "")
alert(hidField.value);
hidField.value = "";
}
</script>

And finally add onLoad event (jscript event) to your body
tag in your html:

<body onLoad="checkError();">

Now every time you need to send any message from your c#
(vb) to the client, just assign any string to the hidField
value in your c# (vb).

That's it.

Regards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top