In ASP, a window is displayed, prompting "no data ". Do not refresh the parent window.

Source: Internet
Author: User

There is a page number control on the ASP page.

<Pagertemplate> <Table width = "100%"> <tr class = "tdbg" align = "center"> <TD style = "height: 39px; text-align: center "class =" paginator "> total <% = This. pagecount %> page number of data entries: <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 entries per page <asp: linkbutton id = "linkbuttonfirstpage" runat = "server" commandargument = "first" commandname = "page" enabled = '<% # (gridview) container. namingcontainer ). pageindex! = 0%> '> homepage </ASP: linkbutton> <asp: linkbutton id = "linkbuttonpreviouspage" runat = "server" commandargument = "Prev" commandname = "page" enabled = '<% # (gridview) container. namingcontainer ). pageindex! = 0%> '> previous page </ASP: linkbutton> <asp: linkbutton id = "linkbuttonnextpage" runat = "server" commandargument = "Next" commandname = "page" enabled = '<% # (gridview) container. namingcontainer ). pageindex! = (Gridview) container. namingcontainer ). pagecount-1%> '> next page </ASP: linkbutton> <asp: linkbutton id = "linkbuttonlastpage" runat = "server" commandargument = "last" commandname = "page" enabled = '<% # (gridview) container. namingcontainer ). pageindex! = (Gridview) container. namingcontainer ). pagecount-1%> '> last page </ASP: linkbutton> to the <asp: textbox id = "txtnewpageindex" runat = "server" width = "20px" text = '<% # (gridview) container. parent. parent ). pageindex + 1%> '/> page <asp: linkbutton id = "btngo" runat = "server" causesvalidation = "false" commandargument = "-1" commandname = "page" text = "go"/> </TD> </ tr> </table> </pagertemplate>

Total number of data items: This. pagecount.

It is a variable in the background. C #

# Total number of region pages Public String pagecount {get {return viewstate ["pagecount"]. tostring () ;}set {viewstate ["pagecount"] = value ;}# total number of endregion pages

In the page load event of C #, assign the pagecount value to the initial value.

ViewState["pageCount"] = 0;

On the ASP page: An export button,

<Input type = "Submit" name = "searchpos0" value = "Export" id = "btnsearch0" class = "inputbutton" onmouseover = "this. classname = 'inputbutton _ hover '"runat =" server "onmouseout =" this. classname = 'inputcall' "onserverclick =" exportexcelstaff1click "onclick =" Return checkexport () "/>

JS script:

<SCRIPT>

Function checkexport (){

VaR n = <% = This. pagecount %>; ----------------------------- call the C # background variable.
If (n> 0 ){
Return true;
} Else {
Alert ("no data export ");
Return false;
}
}
</SCRIPT>

In this way, the prompt window is displayed. Click OK. The parent page is not refreshed.

Method 2:

In the C # code, determine the total number of data sources. When the number is 0, a window is displayed.

This. response. Write ("<script language = JavaScript> alert ('No data is exported! '); Window. Window. Location. href = 'bu36524analyse. aspx'; </SCRIPT> ");

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.