如何在asp.net C#中快速加载我的网站#

时间:2014-05-19 07:06:27

标签: c# asp.net

NET 4.5 c#用于我的购物门户网站。我正在使用Repeater来展示产品,我也使用标签来显示购物车产品数量。但我的问题是每次我将产品添加到购物车整页加载。我尝试过更新面板,但这也没有用。请建议我使用我的网站加载更快,并每次停止产品加载。

My master page where cart info is displayed is like this:



     <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

        <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

        <!DOCTYPE html>

        <html xmlns="http://www.w3.org/1999/xhtml">
        <head runat="server">
            <title>Mansha</title>
            <asp:ContentPlaceHolder id="head" runat="server">
            </asp:ContentPlaceHolder> <link href="Styles/Main.css" rel="stylesheet" />

            <link href="main.css" rel="stylesheet" />
            <link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
            <link rel="stylesheet" type="text/css" href="css/bootstrap-responsive.css" />
             <script type="text/javascript" src="script2.js"></script>
            <script type="text/javascript" src="script.js"></script>
            <script type="text/javascript" src="sliderengine/jquery.js"></script>
            <script type="text/javascript" src="sliderengine/jquery.hislider.js"></script>
            <script src="js/bootstrap.js"></script>
            <script src="js/bootstrap.min.js"></script>
            <link rel="stylesheet" type="text/css" href="css/mystyle.css" />

            <link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" />

            <style>
                html, body {
                    height: 100%;
                    margin: 0px;
                }

                .dropdown-menu {
                    display: block;
                    margin: 0px!important;
                    background-color: #B7002D;
                    border-radius: 0px;
                }

                    .dropdown-menu > li > a {
                        color: #ffffff;
                        margin: 2px 0px;
                    }

                        .dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus, .dropdown-submenu:hover > a, .dropdown-submenu:focus > a {
                            background-color: #CC0033;
                            background-image: none;
                        }

                p {
                    margin: 0px 0px!important;
                }

                @media (max-width: 979px) {
                    .navbar-inverse .nav-collapse .nav > li > a:hover, .navbar-inverse .nav-collapse .nav > li > a:focus, .navbar-inverse .nav-collapse .dropdown-menu a:hover, .navbar-inverse .nav-collapse .dropdown-menu a:focus {
                        background-color: #b7002d!important;
                        -webkit-background-color: #b7002d!important;
                    }

                    .navbar-inverse .nav-collapse .nav > li > a, .navbar-inverse .nav-collapse .dropdown-menu a {
                        color: #ffffff!important;
                        -webkit-color: #ffffff!important;
                    }

                    .mardrop {
                        margin-top: -2px!important;
                    }
                }
            </style>

            <script type="text/javascript">
                $(document).ready(function () {






                    $("#show_div").mouseover(function () { $("#hello").css('visibility', 'visible'); });
                    $("#hello").mouseover(function () { $("#hello").css('visibility', 'visible'); });
                    $("#hello").mouseout(function () { $("#hello").css('visibility', 'hidden'); });
                    $("#show_div").mouseout(function () { $("#hello").css('visibility', 'hidden'); });
                }); </script>


        </head>
        <body>
            <form id="form1" runat="server">
                <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>

                <asp:UpdatePanel ID="UpdatePanel1"  UpdateMode ="Always"  ChildrenAsTriggers ="true"   runat="server">
                    <ContentTemplate >



           <%--<header>
            <div class="container">
                <div class="span12" style="margin-left:0px;">

                   <div class="text-right shortcuts" style="margin-bottom:0px;">


                       <asp:LoginView ID="LoginView1" runat="server">
                           <LoggedInTemplate >


                               <asp:LoginName ID="LoginName1" style="text-transform :uppercase ;" ForeColor="White" runat  ="server" />
                        <i>    <a  style="color:white ;" href="Login/Logout.aspx">Logout</a></i>  
                           </LoggedInTemplate>
                           <AnonymousTemplate >
         <asp:LinkButton ID ="lnkSignUp" runat ="server" CssClass="recent" OnClick="lnkSignUp_Click" >Register | Login</asp:LinkButton>  


                           </AnonymousTemplate>

                       </asp:LoginView>

                   </div>

                </div>
            </div> 
        </header>
             <div class="container">
                <div class="row-fluid header_section no-margin">

                    <div class="span6" style="margin-left:0px;">
                        <div class="text-left" style="margin-left:0px;">
                            <img src="../images/logo7.png" alt="Logo" longdesc="index.html" />
                        </div>
                    </div>
                    <div class="span4 "><p class="text-center phno style="margin-left:0px;""><img src="../images/chef.png" width="54" height="71" alt="cart"/>
                    0128-244-9786</p></div>
                    <div class="span2"> <p class="text-right"><a href="ViewCart.aspx"><img src="../images/url.jpeg" width="78" height="71" alt="cart"/></a>(<asp:Label ID="lblCart" Text ="0" runat="server"></asp:Label>)</p></div>        

                </div>
             </div>
            <!-- <div style="height:60px">
                <img src="Hitch Logo New.png" width="70" height="71" alt="Logo" longdesc="index.html" />
            </div> -->
            <div class="container">     
                 <div class="navbar navbar-inverse">
                    <div class="navbar-inner">
                        <div class="container-fluid">
                            <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                                <span class="icon-bar"></span>
                                <span class="icon-bar"></span>
                                <span class="icon-bar"></span>
                            </button>
                          <a class="brand" href="#"></a>
                          <div class="nav-collapse collapse">                   
                            <ul class="nav">
                              <li class="active"><a href="index.aspx">Home</a></li>
                              <li><a href="#about">About</a></li>
                              <li class="dropdown">
                                <a href="#" id="show_div" class="dropdown-toggle" data-toggle="dropdown">Products <b class="caret"></b></a>
                                  <div id="hello" style="visibility:hidden;"> 
                                    <ul class="dropdown-menu">
                                      <li><a href="#">Gulab Jamun</a></li>
                                      <li><a href="#">Kaju Barfi</a></li>
                                      <li><a href="#">Barfi</a></li>  
                                      <li><a href="productpage.html">Jalebi</a></li>
                                      <li><a href="#">Laddu</a></li>                              
                                    </ul>
                                    </div>
                              </li>

                              <li><a href="#contact">Contact</a></li>

                            </ul>
                          </div><!--/.nav-collapse -->
                        </div>
                    </div>
                 </div>

                ///////////////////////////////////////////////////////////////////////////////////////////////////--%>
        <header>
            <div class="container">
                <div class="span12" style="margin-left:0px;">

                   <div class="text-right shortcuts" style="margin-bottom:0px;">
                       <asp:LoginView ID="LoginView1" runat="server">
                           <LoggedInTemplate >


                               <asp:LoginName ID="LoginName1" style="text-transform :uppercase ;" ForeColor="White" runat  ="server" />
                        <i>    <a  style="color:white ;" href="Login/Logout.aspx">Logout</a></i>  
                           </LoggedInTemplate>
                           <AnonymousTemplate >
         <asp:LinkButton ID ="lnkSignUp" runat ="server" CssClass="recent" OnClick="lnkSignUp_Click" >Register | Login</asp:LinkButton>  


                           </AnonymousTemplate>

                       </asp:LoginView>
                   </div>

                </div>
            </div> 
        </header>
             <div class="container">
                <div class="row-fluid header_section no-margin">

                    <div class="span6" style="margin-left:0px;">
                        <div class="text-left imag" style="margin-left:0px;">
                        <a href="index.aspx">   <img src="images/new_mansha_logo.jpg" style="width:100%; height:100%;" alt="Logo" longdesc="index.html" /></a>
                        </div>
                    </div>
                    <div class="span4 "><p class="text-center phno style="margin-left:0px;""><img src="images/chef.png" width="54" height="71" alt="cart"/>
                    0128-244-9786</p></div>
                    <div class="span2"> <p class="text-right imgmarg"><a href="ViewCart.aspx"><img src="images/url.jpeg" width="50" height="71" alt="cart"/></a>(<asp:Label ID="lblCart" Text ="0" runat="server"></asp:Label>)</p></div>       

                </div>
             </div>
            <!-- <div style="height:60px">
                <img src="Hitch Logo New.png" width="70" height="71" alt="Logo" longdesc="index.html" />
            </div> -->
            <div class="container">     
                 <div class="navbar navbar-inverse">
                    <div class="navbar-inner">
                        <div class="container-fluid">
                            <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                                <span class="icon-bar"></span>
                                <span class="icon-bar"></span>
                                <span class="icon-bar"></span>
                            </button>
                          <a class="brand" href="#"></a>
                          <div class="nav-collapse collapse">                   
                            <ul class="nav">
                              <li class="active"><a href="index.aspx">Home</a></li>
                              <li><a href="AboutUs.aspx">About</a></li>
                              <li class="dropdown">
                            <a href="#" id="show_div" class="dropdown-toggle" data-toggle="dropdown">Products <b class="caret"></b></a>
                                 <div id="hello" style="visibility:hidden;" class="hidden-phone hidden-tablet visible-desktop mardrop"> 
                                    <ul id="Menu1" runat ="server"  class="dropdown-menu">
                                      <%--<li><a href="productpage.html">Gulab Jamun</a></li>
                                      <li><a href="#">Kaju Barfi</a></li>
                                      <li><a href="#">Barfi</a></li>  
                                      <li><a href="productpage.html">Jalebi</a></li>
                                      <li><a href="#">Laddu</a></li>        --%>                      
                                    </ul>
                                    </div>
                                    <div id="hello2"  class="hidden-desktop visible-tablet visible-phone mardrop"> 
                                    <ul id="Menu2" runat ="server" class="dropdown-menu">
                                      <%--<li><a href="productpage.html">Gulab Jamun</a></li>
                                      <li><a href="#">Kaju Barfi</a></li>
                                      <li><a href="#">Barfi</a></li>  
                                      <li><a href="productpage.html">Jalebi</a></li>
                                      <li><a href="#">Laddu</a></li>    --%>                          
                                    </ul>
                                    </div>
                              </li>

                              <li><a href="ContactUs.aspx">Contact</a></li>

                            </ul>
                          </div><!--/.nav-collapse -->
                        </div>
                    </div>
                 </div>













            <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

            </asp:ContentPlaceHolder>
     <div class="clearfix"></div>
    <footer>
        <div class="container">
                         <div class="span12 footer_botm" style="margin-left:0px;">

                       <div class="span2 footer_sub_botm text-left" style="margin-left:0px;"><b class="botm_undr">Information</b>

                       <ul class="unstyled">
                                <li>About US</li>
                                <li>Contact US</li>
                                <li>Products</li>
                        </ul>
                       </div>

                       <div class="span2 footer_sub_botm text-left" style="margin-left:0px;"><b class="botm_undr">Products</b>

                       <ul class="unstyled">
                                <li>Jalebi</li>
                                <li>Kaju Barfi</li>
                                <li>Pista Badaam Barfi</li>
                        </ul>
                       </div>


                        <div class="span2 footer_sub_botm text-left" style="margin-left:0px;"><b class="botm_undr">Account</b>

                       <ul class="unstyled">
                                <li>Login</li>
                                <li>Create Account</li>
                                <li>My Bag</li>
                        </ul>
                       </div>



                         <div class="span2 footer_sub_botm text-left" style="margin-left:0px;"><b class="botm_undr">Legals</b>

                       <ul class="unstyled">
                                <li>Site Map</li>
                                <li>Stock Availability</li>
                                <li>Terms & Conditions</li>
                                <li>Privacy Policy</li>
                        </ul>
                       </div>
                       <div class="span2 footer_sub_botm text-left" style="margin-left:0px;"><b class="botm_undr">Contact Us</b>
                       <ul class="unstyled">
                       <li>house No 222, Sector3</li>
                       <li>Main Market, Usa</li>
                       <li>Call On: <b>+91-9997778880</b></li>

                       </ul></div>

                        <div class="span2 footer_sub_botm text-right" style="margin-left:0px;">
                               <i class="fa fa-youtube fsz fa-inverse"></i>
                               <i class="fa fa-twitter-square fsz fa-inverse"></i>
                               <i class="fa fa-facebook-square fsz fa-inverse"></i>
                               <div class="span2" style="margin-left:0px;">Feedback<i class="fa fa-thumbs-o-up fsz fa-inverse"></i></div>

                       </div>


            </div>
            <div class="span12 text-center hidden-phone hidden-tablet"  style="margin-left:0px;color:#ffffff;">
            Powered By <a href="http://www.hitchtechnologies.com/"><img src="images/Hitch Logo BW.png"></a>
            &nbsp;&nbsp;&nbsp;©The Mansha Sweets.All rights reserved.</div>
            <!-- <div class="span7 text-center hidden-phone hidden-tablet"  style="margin-left:0px;color:#ffffff;">©The Mansha Sweets.All rights reserved.</div>
            <div class="span5 text-center hidden-phone hidden-tablet pull-right"  style="margin-left:0px;color:#ffffff;">
            Powered By <a href="http://www.hitchtechnologies.com/">Hitch Technologies</a></div> -->

        </div>
    </footer>
            <asp:ModalPopupExtender ID="ModalPopupExtender1" PopupControlID="pnlLogin" BackgroundCssClass="modalBackground" TargetControlID ="lnkFake" runat="server">

            </asp:ModalPopupExtender>
            <asp:LinkButton ID ="lnkFake" runat="server" ></asp:LinkButton>
            <asp:Panel ID="pnlLogin" CssClass ="popupmain"    runat="server" >
                <asp:ImageButton ID="imgClose" style="margin-left:0px!important;" ImageUrl="~/CmnImages/popupclose.png" runat="server" />
    <div  class="leftsec ">
        <div class ="headng" >Create a new account</div>
    <table>
        <tr><td><asp:TextBox ID ="txtFName" style="color:#AEAEAE;" onfocus="if(this.value=='FIRST NAME!') this.value='';"
            onblur="if(this.value=='') this.value='FIRST NAME!';"  runat ="server" >FIRST NAME!</asp:TextBox></td><td>

                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate ="txtFName" ForeColor="Red"  InitialValue ="FIRST NAME!" ValidationGroup="s" runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
                                                                                                                  </td></tr>
          <tr><td><asp:TextBox ID ="txtLName" style="color:#AEAEAE;" onfocus="if(this.value=='LAST NAME!') this.value='';"
            onblur="if(this.value=='') this.value='LAST NAME!';" runat ="server" >LAST NAME!</asp:TextBox></td><td>

                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate ="txtLName" ForeColor="Red" ValidationGroup="s"  InitialValue ="LAST NAME!" runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>

                                                                                                               </td></tr>
         <tr><td><asp:TextBox ID ="txtEmail" style="color:#AEAEAE;"  onfocus="if(this.value=='EMAIL!') this.value='';"
            onblur="if(this.value=='') this.value='EMAIL!';" runat ="server" >EMAIL!</asp:TextBox></td><td>

                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ForeColor="Red" ControlToValidate ="txtEmail" runat="server" ErrorMessage="*" ValidationGroup="s"></asp:RegularExpressionValidator>
                                                                                                       </td></tr>
         <tr><td><asp:TextBox ID ="txtPassword"  PlaceHolder="PASSWORD!"  TextMode="Password" runat ="server" >PASSWORD!</asp:TextBox></td><td>

                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ForeColor="Red" ValidationGroup="s" InitialValue="PASSWORD!" ControlToValidate="txtPassword"    runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
                                                                                                             </td></tr>
        <tr><td><asp:LinkButton ID ="lnkRegister" CssClass ="primary" ValidationGroup="s"  runat ="server" OnClick="lnkRegister_Click1" >CREATE MY ACCOUNT</asp:LinkButton></td><td></td></tr>
    </table></div>
                <div class="separatorparent">
    <div class ="separator" >

        <div>OR</div>

    </div></div>
                <div class="rightsec">


     <asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false"
                OnAuthenticate="LoginUser_Authenticate">
                <LayoutTemplate>
                    <asp:Panel ID="Panel1" runat="server" DefaultButton="lnkSubmit">
                         <div class ="headng" >Login to my account</div>
                            <ul style="" class="field_set login" id="login_content">

                                <li class="mbs">

            <asp:TextBox ID="UserName" style="color:#AEAEAE;"    onfocus="if(this.value=='EMAIL!') this.value='';"
            onblur="if(this.value=='') this.value='EMAIL!';" runat ="server" >EMAIL!</asp:TextBox>

                                    <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
                                        CssClass="failureNotification" ForeColor="Red" InitialValue="EMAIL!" ErrorMessage="User Name is required." ToolTip="User Name is required."
                                        ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
                                </li>
                                <li id="login_form_password">

       <asp:TextBox ID="Password" runat="server"  PlaceHolder="PASSWORD!"  TextMode="Password"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
                                        CssClass="failureNotification" ErrorMessage="Password is required." ForeColor="Red"  ToolTip="Password is required."
                                        ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
                                </li>
                                <li>
                                    <input type="hidden" value="" name="_pw_sql" id="_pw_sql">
                                </li>
                                <li class="mbs">

                                        <asp:CheckBox ID="RememberMe" runat="server" v-align="middle" Text="Remember me" /></label>

                                <li class="forgot_password" style="text-align: right;">
                                    <%-- <asp:LinkButton ID="lnkSubmit" runat="server" CssClass="sales_button blue_button_small login_form_button_login"
                                    CommandName="Login" Text="Log In" ValidationGroup="LoginUserValidationGroup"></asp:LinkButton>--%>
                                    <asp:LinkButton ID="lnkSubmit" runat="server" CssClass ="primarylogin"
                                        CommandName="Login" Text="Login" 
                                        ValidationGroup="LoginUserValidationGroup"></asp:LinkButton> 


                                </li>
                                <li><%--<a href="../login/PassRecovery.aspx" rel="push" class="RegLinks">Forgot
                                    your user name ?</a><br />--%>
                                    <a href="../login/PassRecovery.aspx" rel="push" class="RegLinks">Forgot your
                                        password ?</a></li>
                                </li>

                                <div class="loginvalidationsummary" style="display :none;">
                                    <asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification"
                                        ValidationGroup="LoginUserValidationGroup" ForeColor="White" />
                                    <span class="failureNotification">
                                        <asp:Literal ID="FailureText"  runat="server"></asp:Literal>
                                    </span>
                                </div>

                            </ul>

                    </asp:Panel>
                </LayoutTemplate>
            </asp:Login>



    <%--<table  >
        <tr><td><asp:TextBox ID ="txtLoginEmail"  onfocus="if(this.value=='EMAIL!') this.value='';"
            onblur="if(this.value=='') this.value='EMAIL!';" runat ="server" >EMAIL!</asp:TextBox></td><td> 

     <asp:RegularExpressionValidator ID="RegularExpressionValidator2" ForeColor="Red" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate ="txtLoginEmail" runat="server" ErrorMessage="*" ValidationGroup="l"></asp:RegularExpressionValidator>


                                                                                                       </td></tr>
         <tr><td><asp:TextBox ID ="txtLoginPassword"  onfocus="if(this.value=='PASSWORD!') this.value='';"
            onblur="if(this.value=='') this.value='PASSWORD!';" runat ="server" >PASSWORD!</asp:TextBox></td><td>

     <asp:RequiredFieldValidator ID="RequiredFieldValidator4" ForeColor="Red" ValidationGroup="l" InitialValue="PASSWORD!" ControlToValidate="txtLoginPassword"    runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
            <tr><td> <asp:CheckBox ID ="chkRemeber" runat ="server"  Text ="Remember me" /></td></tr> 
                                                                                                             </td></tr>
        <tr><td><asp:LinkButton ID ="lnkLoginSubmit" ValidationGroup="l" CssClass ="primarylogin"    runat ="server" OnClick="lnkLoginSubmit_Click1" >LOGIN</asp:LinkButton></td><td></td></tr>

    </table>--%></div>



            </asp:Panel>

              </ContentTemplate>
            </asp:UpdatePanel>
        </form>
    </body>
    </html>

我正在使用转发器在内容页面上显示我的产品

1 个答案:

答案 0 :(得分:1)

这是因为您没有在分页查询中使用ajax。使用任何jQuery网格,并在数据库中编写分页查询以获取分页结果。永远不要使用Microsoft的Ajax Control Toolkit,即使Microsoft建议使用jQuery(http://www.jquery4u.com/plugins/10-jquery-grids/

寻呼查询:SQL Server paging query