Ajax ModelPopu and Progress 示例学习

ModelPopu示例:

1.先创建一个ASP.NET WEB项目;

2.为项目中添加一个CSS文件,代码如下所示:

.modalBackground
{
      background-color: blacks;
      filter: alpha(opacity=60);
      opacity: 0.6;
}
.modalPopup
{
      background-color:#ffffdd;
      border-width:3px;
      border-style:solid;
      border-color:black;
      padding:5px;
      width: 350px;
      height:300px;
}

3.把AJAX控件引用到工具箱中去;

4.为默认页面中添加控件,代码如下:

<asp:ScriptManager ID="ScriptManager1" runat="server" />
       Are you sure you want to know the answer?.
       <asp:Button ID="btnYes" runat="server" Text="Yes!" />
       <br />
       <asp:Panel ID="pnlModal" runat="server" CssClass="modalPopup" Style="display: none;">
           Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque
           laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi
           architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas
           sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione
           voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor
           sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt
           ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam,
           quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid
           ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate
           velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo
           voluptas nulla pariatur?
           <br />
           <asp:Button ID="btnClose" runat="server" Text="Close" />
       </asp:Panel>

5.把鼠标放在Panel控件上,会出现智能扩展,代码如下:

<cc1:ModalPopupExtender TargetControlID="btnYes" ID="pnlModal_ModalPopupExtender"
            runat="server" DynamicServicePath="" Enabled="True" BackgroundCssClass="modalBackground"
            PopupControlID="pnlModal" CancelControlID="btnClose" DropShadow="true">
        </cc1:ModalPopupExtender>
参数说明:
TargetControlID:为目标控件,以就是说单击那一个控件后,回出现什么的那一个控件;
PopupControlID:为弹出的控件;
CancelControlID:为取消时的控件;
运行效果如下所示:
rr 
 
示例二   Progress 
1.创建一个ASP.NET WEB 项目
2.为默认页面中添加如下代码:
 
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdateProgress ID="updProgress" 
   AssociatedUpdatePanelID="UpdatePanel1" runat="server">
            <ProgressTemplate>
                <img alt="progress" src="../Image/progress.gif" />
                Processing...
            </ProgressTemplate>
        </asp:UpdateProgress>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Label ID="lblText" runat="server" Text=""></asp:Label>
                <br />
                <asp:Button ID="btnInvoke" runat="server" Text="Click" OnClick="btnInvoke_Click" />
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>
说明:
AssociatedUpdatePanelID:这个是他的合作控件;
2.为BUTTON添加如下事件:
System.Threading.Thread.Sleep(3000);
Response.Redirect("WebForm1.aspx");
运行如下:
image 
最后到WebForm1.aspx页面中
完成!希望对初学者有所帮助;
睡觉了,明天还得上班,明晚再见!
 
 
posted @ 2009-04-21 22:16  阳光追梦  阅读(836)  评论(2编辑  收藏  举报
/*快速评论*/ #div_digg { position: fixed; bottom: 10px; right: 15px; border: 2px solid #ECD7B1; padding: 10px; width: 140px; background-color: #fff; border-radius: 5px 5px 5px 5px !important; box-shadow: 0 0 0 1px #5F5A4B, 1px 1px 6px 1px rgba(10, 10, 0, 0.5); } /** 不知道为什么页面加载完成时还读不到div_digg。可能也是动态生成的。 所以这里只能用定时器 不断的读取,当读取到了再给它动态添加快捷按钮 **/ //自定义 定时器[当元素加载完成是执行回调函数] function customTimer(inpId,fn) { if ($(inpId).length) { fn(); } else { var intervalId = setInterval(function () { if ($(inpId).length) { //如果存在了 clearInterval(intervalId); // 则关闭定时器 customTimer(inpId,fn); //执行自身 } }, 100); } } //页面加载完成是执行 $(function () { customTimer("#div_digg", function () { var div_html = "
\ 关注\  | \ 顶部\  | \ 评论\
"; $("#div_digg").append(div_html); //tbCommentBody }); });