ajaxToolkit:ModalPopupExtender可以让用户模拟新开一个窗口,以下演示,就是在模拟新开窗口作多项选项的功能。
演示例子中,是Repeater结合CheckBox进行多选,此功能实现,可以参考:http://www.jb51.net/article/33558.htm
选择的小图片,它将要被ajaxToolkit:ModalPopupExtender使用,因为需要设为服务控件,添加runat="server":
复制代码 代码如下:
<img id="ab" runat="server"
src="../Image/ab.gif" width="18" height="18" />
下面是Popup窗口的Html,不过Insus.NET已经省略了Repeater控件内的内容,你在应用时,需要添加的你自己的,还是就是btnSelected_Click事件。
复制代码 代码如下:
<asp:Panel ID="pnlPopupWindown" runat="server">
<asp:Panel ID="Panel3" runat="server">
邮件地址列表
</asp:Panel>
<asp:Panel ID="Panel4" runat="server">
<asp:LinkButton ID="btnClose" runat="server"
OnClientClick="return false;" Text="×" ForeColor="Red" ToolTip="Close" />
</asp:Panel>
<div>
<asp:Panel ID="Panel1" runat="server" ScrollBars="Vertical" Height="198px" Width="100%"
Border BorderWidth="1px" BorderColor="Gray">
<asp:Repeater ID="RepeaterEmailList" runat="server">
</asp:Repeater>
</asp:Panel>
<div>
</div>
<asp:Panel ID="Panel2" runat="server">
<asp:Button ID="btnSelected" runat="server" Text="插入"
CausesValidation="false" CssClass="button" />
</asp:Panel>
</div>
</asp:Panel>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="ab"
PopupControlID="pnlPopupWindown" BackgroundCssClass="modalBackground" CancelControlID="btnClose"
DropShadow="true" PopupDragHandleControlID="Panel3" />
<script type="text/javascript">
function setBodyHeightToContentHeight() {
document.body.style.height = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight) + "px";
}
setBodyHeightToContentHeight();
$addHandler(window, "resize", setBodyHeightToContentHeight);
</script>
最后是CSS样式:
复制代码 代码如下:
/*Modal Popup*/
.modalBackground
{
background-color: Gray;
filter: alpha(opacity=70);
opacity: 0.7;
}