|
|
下面我介绍这个控件的一些使用方法。
首先,在该控件中,有两种事件可以被激发:Linkcliked事件(当消息框内的连接被点击时触发)和Popupclosed事件(当消息框窗口被关闭时触发)。控件有三种方式对这些事件进行处理,而actiontype属性的取值,则决定了这三种方式:
1)messagewindow(默认):默认的弹出窗口方式,将以设置好的Title属性和Text属性为标题和窗口内的文字说明。
2)openlink:此时,控件允许当点击窗口内的文字链接时,将以打开新窗口的方式打开该链接。
3)raiseevenst:当选择该属性时,控件将会在服务端处理linkcliked事件和popupclosed事件。
在使用该控件时是十分方便的,只需要在visual studio .net 中,使用add/remove toolbox功能,选择该控件的dll,之后,该控件就会出现在工具箱中,就可以拖拉的方式放到网页中去应用。
单击该控件,在其设计器中,会发现有丰富的属性(详细的属性,事件说明请参考该控件的文档)。在设计器中的"操作"分类栏中,可以指定控件如何处理当用户关闭窗口和点击窗口内的文字时打开的新链接;在"文字"和"设计"分类栏中,将可以设计弹出消息窗口的字体,颜色,布局(如设置是从左下角还是从右下角弹出);在"行为"分类栏中,可以设置窗口弹出的弹出速度,是否自动在页面加载后就弹出,以及窗口在弹出多久后会自动关闭,窗口是否可以设置为自由拖拉等等。
下面举例通过代码说明如何使用:
在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> |
// Popup.aspx.cs //设置为默认的消息窗口 popupWin.ActionType=EeekSoft.Web.PopupAction.MessageWindow; //设置窗口的标题,消息文字 popupWin.Title="This is popup"; popupWin.Message="<i>Message</i> displayed in popup"; popupWin.Text="Text to show in new window.."; //设置颜色风格 popupWin.ColorStyle=EeekSoft.Web.PopupColorStyle.Green; //设置窗口弹出和消失的时间 popupWin.HideAfter=5000; popupWin.ShowAfter=500; popupWin.Visible=true; |
|
<!-- 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> |
// Anchor.aspx.cs // Handle onclick event .. //设置其响应的事件为onclick popupAnchor.HandledEvent="onclick"; popupAnchor.LinkedControl="spanReopen"; popupAnchor.PopupToShow="popupWin"; popupWin.Visible=true; popupWin.AutoShow=true; |
|