Link to home
Start Free TrialLog in
Avatar of tariqanis
tariqanis

asked on

Using msgBox in ASP.NET

Hi,
When I use a msgBox in ASP.Net 2 the message doesn't pop up in the center of the screen as it does in regular visual basic applications but shows up like a minimized window on the task bar.
Is there a way to correct this?
Thanks
Avatar of tomasgruener
tomasgruener

Can't help you with your problem, but maybe I can save you some trouble... Do you try to popup a MsgBox on the client (so the viewer of the page)? if so, don't use msgbox.
MsgBox is a WinForm control and gets displayed on the server. that means you see the msg box on the server, and all further operation is cancelled, until you click on it.... usually a client can't access the server, this means, that the web application will break.
if you want to display a msgbox to the client, use Javascripts alert.
Avatar of tariqanis

ASKER

Hi tomasgruener:
Thanks for the tip. But is there an easy way to use JavaScript alert with an Asp.Net server control?
Depends on what you want to do... Just to show an example (i show it in c#, don't know the vb.net syntax). Lets say, you have a select on your screen, where you added the runat="server" tag with the id "customerSelect".
Now you can do following:
customerSelect.Attributes.Add("onchange", "alert('You changed the value')");

you could also add it directly to the html markup like this:
<select onchange="alert('You cangeng the value')">

But if you do it in the markup, you don't have control over the call... if you do it on the server side, you could create an outputstring like you need it (for example to include server time in the message)

If you don't get it, the best thing would be to create an empty page and just test this thing... its very simple, once you got it
//Code
customerSelect.Attributes.Add("onchange", "alert('You changed the value')");
 
<!-- Markup -->
<select onchange="alert('You cangeng the value')">

Open in new window

I am sorry I don't get it.....
What is not clear to me is where to place the code if I am using Asp.net mark up:
Let us say I have a button (call it button1), the original mark up will be in the following way:

<asp:button id="button1" runat="server" />

In a case like the above where do I place your code?


ASKER CERTIFIED SOLUTION
Avatar of tomasgruener
tomasgruener

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Wow.... I think I can use this... thanks, I might come back for more....
It works
Very good ;) glad I could help