tags:

views:

305

answers:

3

Hi,

In ASP.NET -->

I want to popup an alert window in the case of an event. I don't have a button, i do not load the page at that event. When I searched i got a lot of java script examples but I can't use them as they work either on a button click or on page load. I just want a pop window to come as soon as I capture a particular event. I keep checking for the events every 5 second, as soon as i capture one event, there is a switch case for the actions to follow according to the event captured. For one particular case, i need one pop up "Sorry" along with an OK button. Can someone tell me what to do.

Thanks

A: 

Most browsers do not support page-load pop-ups because of pop-up blockers. It's better to use a modal dialog, like jQuery's ThickBox add-on (samples are available in the link). ThickBox allows you to fade out the rest of the page and display a messagebox with an OK button in it. You can even put an IFRAME in it, if you want to display an entire page, which acts as a pop-up window, but remains inside the page, thus avoiding pop-up blockers.

Prutswonder
A: 

You could use a ModalPopup which is part of the Ajax Control Toolkit. I have used it many times to display messages, as it's much nicer than a javascript alert. If your event is captured in javascript, you can simply display it. If your event is captured in the ASP.NET code-behind, you can either display it via a page refresh, or you can put it into an UpdatePanel and trigger that, which will cause it to appear without your page refreshing.

SLC
You could also use the Timer Control to update the panel at intervals - http://msdn.microsoft.com/en-gb/library/bb398865.aspx
Dan Diplo
A: 

Hi, am sorry but am very new to asp.net. This is what I need to do..

switch (Presence) {

case YES:
    //Do nothing
    break;


case NO:
    // Pop up a window with text " Sorry " and an OK button

}

I am not going to click on any button before this event, i get this event directly from another system, there is a requirement to check the connection every 5 seconds so i need to check the events every 5 seconds. I can't wait for the page refresh, and am not sure how to use update panel as i don't want to diplay it on my existing page, i want to open a new alert window. Please excuse my ignorance, but can you explain your solution with an example. ( if possible without using java script, ajax etc i have never used them before )

Is there a direct method like 'MessageWindow' present in asp.net ?

Thanks a lot

Sunny