Asynchronous refresh of an ASP. NET control

Source: Internet
Author: User

Requirement: We know that the button control in the ASP. NET is turned on automatically by default, and sometimes we don't want to refresh the entire interface, but just want to refresh it locally.


Although I hate. NET controls, sometimes it's understandable to use. NET controls to be lazy in situations where performance requirements are low.
ASPX page code (only the key code is written):

   <asp:button id= "<span style=" color: #FF0000; " >btnSearch</span> "runat=" server "text=" search "onclick=" btnSearch_Click "/> <asp:scriptmanager id=                        "ScriptManager1" runat= "Server" ></asp:scriptmanager><div id= "divrecordlist" class= "Rptcss" > <%--<div><span> Select </span><span> Customer name </span><span> Customer code </span>< Span> Water Meter code </span></div>--%> <div> <table Style = "width:100%;" > <tr class= "ORDER-HD" > <th class= "Item" sty Le= "WIDTH:96PX;" > select </th> <th class= "item" style= "width:200px;" > Customer name </th> <th class= "item" style= "width:200px;" > Customer Code </th> <th class= "Last" style= "width:200px;"         > Water Meter Coding </th>                       </tr> </table> </div>                               <asp:updatepanel id= "UpdatePanel1" runat= "Server" > <Triggers> <span style= "color: #FF0000;"                            > <asp:asyncpostbacktrigger controlid= "btnsearch"/></span> </Triggers> <ContentTemplate> <asp:panel id= "Pnlnullinfo" runat= "serv                                        Er "cssclass=" Tb-combobar "visible=" false "> <div class=" Item-not-found ">                                    <asp:label id= "Lblnullinfo" runat= "Server" text= "no query to related data" ></asp:Label>                                </div> </asp:Panel>                          <asp:panel id= "Pnlerror" runat= "Server" visible= "false" >          <asp:label id= "Lblerror" runat= "Server" ></asp:Label> &LT;/ASP:PANEL&G                                T                                        <asp:repeater id= "rptrecordlist" runat= "Server" > <HeaderTemplate> <table style= "width:100%;"                                        > </HeaderTemplate> <ItemTemplate> <tr class= "Order-item" > &LT;TD style = "WIDTH:96PX;" class= "Item" > <span style= "MARGIN-RIGHT:4PX;"  ><%# container.itemindex +1%></span> <input type= "Radio"                                            Id= "rbtn1" Value= ' <% #Eval ("Hx_t_watermeterid")%> '/> </td> &LT;TD style= "width: 201px; "class=" Item "><% #Eval (" name ")%></td> <td style=" Widt h:200px; "class=" Item "><% #Eval (" AccountNumber ")%></td> &LT;TD                                        Style= "width:200px;" class= "Last" ><% #Eval ("Hx_fmetercode")%></td> </tr> </ItemTemplate> <footertemplate                                ></table></FooterTemplate> </asp:Repeater>                            <div id= "Diverror" class= "Errordiv" ><span id= "Spnerror" ></span></div> </ContentTemplate> </asp:UpdatePanel> &LT;/DIV&GT;&NBSP;&NBSP;&NB sp;                              <div class= "menu" >                                      <ul>                                          <li id= "one1" onclick= "Settab (' one ', 1 ) "> Recharge </li>                                          <li id= "One2" onclick= "Settab (' One ', 2)" > Void sold Water </li>                                          <li id= "One3" onclick= "Settab (' One ', 3)" > Water withdrawal </li>                                          <li id= "One6" onclick= "Settab (' one ', 6)" > Replace table < /li>                                     </ul>                                 </div>                                  <div class= "menu" style= "Border-top: #cccccc solid 1px;" >                                     <ul>                                          <li id= "one4" onclick= "Settab (' One ', 4)" > Complementary cards </li>                                          <li id= "One5" onclick= "Settab (' One ', 5); Clearcardext ();" > Clear Cards </li>                                         <li id= "One7" onclick= "Settab (' one ', 7 ); Readcardext (); " > Card Reader </li>                                      </ul>                                 </div >  <!--record Operation tab status-->        <asp:hiddenfield id= "<span styl e= "COLOR: #FF0000;" >hidfTagHistory</span> "runat=" Server "value=" 1 "/>
JS Code:
        Record Action tab selected status        function Recorvertag () {            var cur = document.getElementById ("<span style=" color: #FF0000; " >hidfTagHistory</span> "). Value;            Settab ("One", parseint (cur));        }

CS Code:

        Query protected void btnSearch_Click (object sender, EventArgs e) {       string Searchtag = hidfsearchtag.value;            String words = TxtWords.Text.Trim ();            DataTable DT = null;            switch (searchtag)              {                 case "0"://Water Meter code                      dt = Searchinfolistbymetercode (words);                     break;                 case "1"://Customer Code                      break;                Case "2"://Customer Name                      break;                 default:                     break;           }       if (dt = = null| | Dt. rows.count==0)             {                 pnlnullinfo.visible = true;            }            else            {                 pnlnullinfo.visible = false;           }             Rptrecordlist.datasource = dt;             rptrecordlist.databind ();           / /clear Customer details             scriptmanager.registerstartupscript (UpdatePanel1, this.) GetType (), "ScriptKey", "Clearaccountinfo () <span style=" color: #FF0000; " ><span style= "color: #000000;" >;</span>recorvertag ();</span> ", True);       }



Asynchronous refresh of an ASP. NET control

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.