A large number of third-party controls exist. These controls cover all aspects of development, but it is difficult for developers to select a suitable control, so today we recommend a control that can implement the function similar to the pop-up notification message function of MSN:
Download controls: PopupWin
Example
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:
You can see that this control can use IE, MOZILLA, NETSCAPE, and OPERA in various types of browsers, and we can also customize the color and drag the control, such:
The following describes how to use this control.
First, two events can be triggered in the control: the Linkcliked event is triggered when the connection in the message box is clicked) and Popupclosed events are 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 attribute details. For 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" categories, you can design the font and color of the pop-up message window, such as whether to set the layout 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 code illustrates how to use
In popup. aspx:
<!-- Popup.aspx --> <%@ Register TagPrefix="cc1" Namespace="EeekSoft.Web" Assembly="EeekSoft.Web.PopupWin" %><cc1:popupwin id="popupWin" runat="server" visible="False" colorstyle="Blue" width="230px" height="100px" dockmode="BottomLeft" windowscroll="False" windowsize="300, 200"> </cc1: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. For example:
With the following code, You can reset the title Text of the pop-up message window and let it pop up again:
<!-- Anchor.aspx --> <%@ Register TagPrefix="cc1" Namespace="EeekSoft.Web" Assembly="EeekSoft.Web.PopupWin" %> <cc1:popupwin id="popupWin" runat="server" visible="False" colorstyle="Blue" width="230px" height="100px" dockmode="BottomLeft" windowscroll="False" windowsize="300, 200"> </cc1:popupwin> <cc1:popupwinanchor id="popupAnchor" runat="server" changetexts="False"> </cc1: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. reschedcontrol = "spanReopen "; PopupAnchor. PopupToShow = "popupWin "; PopupWin. Visible = true; PopupWin. AutoShow = true; |
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:
The download provided in this article provides the complete code of the control, the CHM file that uses the sample project of the control, and the detailed event Method description of the control, you can run it on vs.net 2003.
(