MSN has a good function, that is, whenever Your MSN friends go online, MSN will automatically pop up a message box in the lower right corner of the form tray to notify you, this function is very practical, for example, when you reply to your post in a forum, the system will automatically pop up a message box, or in an e-government system, when you receive a new email or work order, the system prompts the message box and so on. So how can this function be implemented in Web applications built by ASP. NET? In this article, we recommend a. Net control that can implement notification message window effects similar to MSN. First, let's take a look at the implementation of the control, such: We can see that this control can be used in various types of browsers (ie, Mozilla, Netscape, opera), and we can also customize the color and drag, such: The following describes how to use this control. First, two events can be triggered in the control: linkcliked event (triggered when a connection in the message box is clicked) and popupclosed events (triggered when the message box window is closed ). The control can process these events in three ways. The value of the actiontype attribute determines the three methods: 1) messagewindow (default): the default pop-up window mode. The title and text attributes are set as the title and text description in the window. 2) openlink: the control allows you to open the link in a new window when you click a text link in the window. 3) raiseevenst: When this attribute is selected, the control processes the linkcliked and popupclosed events on the server side. This control is very convenient. You only need. net, use the Add/Remove toolbox function, select the control DLL, the control will appear in the toolbox, you can drag the way to the web page to apply. Click the control. In its designer, you will find a variety of attributes (for details about attributes and event description, see the control documentation ). In the "operations" category bar of the designer, you can specify how the control processes the new Link opened when the user closes the window and clicks the text in the window; in the "text" and "design" Classification columns, you can design the font, color, and layout of the pop-up message window (for example, set to pop up from the lower left or lower right corner ); in the "behavior" category bar, you can set the window pop-up speed, whether to automatically pop up after the page is loaded, and how long the window will automatically close after it appears, whether the window can be set to be dragged freely or not. The following example shows how to use the code: In Popup. aspx: <! -- Popup. aspx --> <% @ Register tagprefix = "PC3" namespace = "eeeksoft. Web" Assembly = "eeeksoft. Web. popupwin" %> <PC3: popupwin id = "popupwin" runat = "server" visible = "false" Colorstyle = "blue" width = "230px" Height = "100px" dockmode = "bottomleft" Windowscroll = "false" windowsize = "300,200"> </PC3: popupwin> Write in code-behind code: // Popup. aspx. CS // Set as the default message window Popupwin. actiontype = eeeksoft. Web. popupaction. messagewindow; // Set the title and text of the window. Popupwin. Title = "this is popup "; Popupwin. Message = "<I> message </I> displayed in popup "; Popupwin. Text = "text to show in New window .."; // Set the Color Style Popupwin. colorstyle = eeeksoft. Web. popupcolorstyle. Green; // Set the time when the window pops up and disappears Popupwin. hideafter= 5000; Popupwin. showafter= 500; Popupwin. Visible = true; On the basis of the control, we can enhance the function of the control to implement a control called popupanchor. This control can dynamically detect client events. For example, in an input form, a message prompt box is displayed whenever you fill in data in the text box and move the focus of the mouse to another text box. You can also use this control to dynamically change the title and text of the original pop-up window. The popipanchor control is used with the popupwin control. For example, if you want to re-open the pop-up window box, you can add a popipanchor control and set the popuptoshow attribute, specify the window in which the message box is to be controlled, and then set the relevant handledevent attribute to specify the event to be sent (such as onfocus and ondblick), as shown in With the following code, You can reset the title Text of the pop-up message window and make it pop up again: <! -- Anchor. aspx --> <% @ Register tagprefix = "PC3" namespace = "eeeksoft. web "assembly =" eeeksoft. web. popupwin "%> <PC3: popupwin id =" popupwin "runat =" server "visible =" false" Colorstyle = "blue" width = "230px" Height = "100px" dockmode = "bottomleft" Windowscroll = "false" windowsize = "300,200"> </PC3: popupwin> <PC3: popupwinanchor id = "popupanchor" runat = "server" changetexts = "false"> </PC3: popupwinanchor> <span id = "spanreopen"> click here to reopen popup! </Span> the code in the code-behind file is as follows: // anchor. aspx. CS // Handle onclick event .. // Set the response event to onclick. Popupanchor. handledevent = "onclick"; popupanchor. inclucontrol = "spanreopen "; Popupanchor. popuptoshow = "popupwin "; Popupwin. Visible = true; Popupwin. autoshow = true; then the above Code can be implemented. When you click the spanreopen area, the pop-up message window will pop up again. The demo shows how to use the popupanchor control. For example, when you click the first text box, a dialog box is displayed, prompting you to enter text. When you enter the content of the first text box, when you move the cursor to the second text box, the second window is displayed: |