What is the .NET/C# Web Application version of Messagebox.Show???

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hey guys,

I am writing a web app using C#/ASP/.NET/Whatever... I'd like to have
a window pop-up with some text. Basically, I'm trying to find out what the
MessageBox.Show or the Console.Writeline is for web page apps.

I know how to make pop-up text boxes in Javascript or in Cold Fusion, but I
was wondering if there was something for .NET/C#?


Thanks!

Todd
 
Todd,

The C#/Asp.Net environment is basically just a very very fancy html
generator.

So there are not "pop up windows ~~in~~ asp.net".

As another example, asp.net has a calendar control.
There isn't such thing as a browser calendar control.
The asp.net calendar control basically just automatically codes up the html
for a <table> and all the numbers in the proper place, and generates the
javascript onClick events.

Once you get that basic rule of thumb down, the mindset will be easier.

Now get me wrong, its a ~great (and fancy) creator, and I wouldn't go back
to anything else.


Howver, you can code up some javascript to pop a window.

Look for (google) .RegisterClientScript, which is the code behind way (.cs
file) of pushing javascript out to the client.

But at the end of the day, what gets pushed out to the client is just html
(and javascript)
 
Well, you cant actually pop message boxes in asp.net, as its a server side
technology that delivers text to be rendered. So if you know how to do it
in javascript your already most of the way there. Theres a code snippet
below to help you see how to implement it.

The equivalent of console.writeline would be response.write().

--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com


<html>
<head>
<script language="VB" runat="server">
Sub Page_Load( sender as Object,e as EventArgs)
'Form the script that is to be registered at client side.
Dim scriptString as String = "<script language=JavaScript> function
DoClick() {"
ScriptString += "var truthBeTold = window.confirm('Click OK to continue.
Click Cancel to stop.');"
ScriptString += "if (truthBeTold)"
ScriptString += "window.alert('Welcome to MVP World!');"
ScriptString += "else window.alert('Bye from MVP World!');}<"
scriptString += "/"
scriptString += "script>"
If(Not IsClientScriptBlockRegistered("clientScript"))
RegisterClientScriptBlock("clientScript", scriptString)
End If
End Sub
</script>
</head>
<body topmargin="20" leftmargin="10">
<form id="myForm" runat="server">
<input type="button" value="ClickMe" onclick="DoClick()">
</form>
</body>
</html>
 

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

Back
Top