asp.net of the JS-content page of the method _javascript skills

Source: Internet
Author: User

Code in the Default.aspx.cs

protected int pageIndex = 1;
protected int pageSize = ten;
protected int pagecount = m;
Protected string name = String. Empty;
protected void Page_Load (object sender, EventArgs e)
{
 int. TryParse (request.querystring["PageIndex"],out pageIndex);
 name=request.querystring["name"];
 

Code in the Default.aspx.cs

The contents of the body

Name: <input type= "text" id= "txtname" value= "<%=name%>" "/> <div id=" Pagebar "
  >

The content of JS

<script src= "Jquery-1.4.1.js" type= "Text/javascript" ></script> <script type= "Text/javascript" >
  var pagecount=<%=pagecount%>;
  var pageindex=<%=pageindex%>;
  var pagesize=<%=pagesize%>;
  $ (function () {Createpagebar (pageindex,pagecount);
   )//Raw ingredient page Bar function Createpagebar (pageindex,pagecount) {//Get the div that holds the pagination and empty the Var pagebarobj=$ (' #PageBar ');
   
   
   Pagebarobj.html (");
   Determines the given page number if (pageindex<1) {pageindex=1;
   } if (Pageindex>pagecount) {pageindex=pagecount; //home page with previous $ (' <a href= "javascript:void (0)" > Home </a> '). Appendto (Pagebarobj). Click (function () {Gopage
   (1);

   });
      if (pageindex>1) {$ (' <a href= ' javascript:void (0) ' > Prev </a> '). Appendto (Pagebarobj). Click (function () {
     Gopage (pageindex-1);
   });
   }//Digital paging var start=pageindex-4;
   if (start<1) {start=1;
   } var end=start+9;
   if (end>pagecount) {end=pagecount; }

   for (Var i=start;i<=end;i++) {$ (' <a href= "javascript:void (0)" >[' +i+ "]</a> '). Appendto (Pagebarobj).
    Click (function () {gopage (i);
   }); //Next and last if (Pageindex<pagecount) {$ (' <a href= ' javascript:void (0) ' > next page </a> '). Appendto (Pagebar
     OBJ). Click (function () {gopage (pageindex+1);
   });
   } $ (' <a href= ' javascript:void (0) ' > Last </a> '). Appendto (Pagebarobj). Click (function () {gopage (PageCount);

  });
    //GO Jump function Gopage (pageindex) {var name=$ (' #txtName '). Val ();
  window.location= "/default.aspx?pageindex=" +pageindex+ "&name=" +name; } </script>

The above asp.net of the JS-content page of the method is small to share the whole of the contents of everyone, I hope to give you a reference, but also hope that we support the cloud-dwelling community.

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.