ASP中弹出窗口,提示“没有数据”。不刷新父窗口。


在ASP页面上,有一个页码的控件。

 <PagerTemplate>
                <table width="100%">
                    <tr class="tdbg" align="center">
                       <td style="height: 39px; text-align: center"  class="paginator">
                            共<%=this.PageCount %>条数据      页码:
                            <asp:Label  ID="LabelCurrentPage" runat="server"
                                    Text="<%# ((GridView)Container.NamingContainer).PageIndex + 1 %>"></asp:Label>
                                /
                            <asp:Label ID="LabelPageCount" runat="server"
                            Text="<%# ((GridView)Container.NamingContainer).PageCount %>"></asp:Label> 页
                             每页15条
                            <asp:LinkButton ID="LinkButtonFirstPage" runat="server" CommandArgument="First" CommandName="Page"
                            Enabled='<%#((GridView)Container.NamingContainer).PageIndex != 0 %>'>首页</asp:LinkButton>
                            <asp:LinkButton ID="LinkButtonPreviousPage" runat="server" CommandArgument="Prev" CommandName="Page"
                             Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>'>上一页</asp:LinkButton>
                             <asp:LinkButton ID="LinkButtonNextPage" runat="server" CommandArgument="Next" CommandName="Page"
                              Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>'>下一页</asp:LinkButton>
                            <asp:LinkButton ID="LinkButtonLastPage" runat="server" CommandArgument="Last" CommandName="Page"
                             Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>'>尾页</asp:LinkButton>
                              转到第
                            <asp:textbox id="txtNewPageIndex" runat="server" width="20px" text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>' />页
                            <asp:linkbutton id="btnGo" runat="server" causesvalidation="False" commandargument="-1"  commandname="Page" text="GO" />
                        </td>
                    </tr>
                </table>
             </PagerTemplate>

数据的总条数:this.PageCount.

在后台是一个变量。C#

#region 页码总数
        public string PageCount
        {
            get
            {
                return ViewState["pageCount"].ToString();
            }
            set
            {
                ViewState["pageCount"] = value;
            }
        }
        #endregion 页码总数

在C#的页面Load事件中,将pageCOunt赋初值。

ViewState["pageCount"] = 0;


在ASP页面中:一个导出按钮,

 <input type="submit" 
                            name="SearchPOS0" value="导出" id="BtnSearch0" class="inputbutton"
                            οnmοuseοver="this.className='inputbutton_hover'" runat="server" 
                            οnmοuseοut="this.className='inputbutton'"  
                            onServerClick="ExportExcelStaff1Click" οnclick="return checkExport()"/>

js脚本:

<script>

function checkExport() {

        var n = <%=this.PageCount%>; -----------------------------调用C#后台的变量。
        if (n>0) {
            return true;
        } else {
            alert("没有数据导出");
            return false;
        }
    }
</script>


这样就能达到,弹出了提示窗口,点击确定之后。父页面不刷新。


方法二:


在C#代码中,判断数据源的总条数,当条数为0的时候,弹出窗口。

this.Response.Write(" <script language=javascript>alert('没有数据导出!');window.window.location.href='Bu36524Analyse.aspx';</script>");


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值