English 中文(简体)
如何加速使用j Query的蚊帐页
原标题:How to speed up an asp.net page that uses jQuery

我有一个网页,使用户能够将信息输入形式。 我在网页上和后面的代码上都使用一些 j,我需要找到加快页速度的方法(大约需要30秒钟的负荷)。 我确信,有一些非常容易的固定装置,可以加快网站的负荷,下文是该网站的一些幻灯。 任何帮助都会大大加快现场的负荷工作。

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">

  <script type="text/javascript">
      $(document).ready(function () {
          var i = $("table.newRequirementClass tr td:contains( Description )").next();

          i.textLimiter({
              maxLength: 255,
              elCount:  elCount 
          });
          $("#submitMIFields").hide();
          $("#submitMIFields").toggle(false);
          $("[id$= chkMI ]").change(function () {
              $("#submitMIFields").toggle("slow");
          });

          $(".MIHead").hide();
      });

      function Count(text, maxLength) {
          if (text.value.length > maxLength) {
              text.value = text.value.substring(0, maxLength);
          }
      }
   </script>

<div style="text-align: left; width: 80%;">
        <h2 runat="server" id="h2Caption">New Requirement</h2>
        <asp:Panel ID="ErrorSummary" runat="server">
        <asp:Label runat="server" ID="lblErrors" />
        <asp:ValidationSummary id="valSummary" runat="server"
        HeaderText="Please Revise The Following Errors:"
        ShowSummary="true" DisplayMode="List" />

        </asp:Panel>
        <asp:DetailsView ID="dvNewRequirement" 
            runat="server"  CssClass="newRequirementClass"
            AutoGenerateRows="False" 
            Width="100%"
            DefaultMode="Insert"
            SkinID="SampleDetailsView" 
            CssSelectorClass="PrettyDetailsView" 
            OnItemInserting="dvNewRequirement_ItemInserting" 
            OnModeChanging="dvNewRequirement_ModeChanging" 
            ondatabound="dvNewRequirement_DataBound" >
            <FieldHeaderStyle Width="15em" Font-Bold="True"/>
            <Fields>
                <asp:TemplateField HeaderText="Status">
                    <InsertItemTemplate>
                    <asp:Label ID="lblStatus" Text="Pre-Solicitation" runat="server" />

                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Vehicle:" Visible="false" >
                    <InsertItemTemplate>
                        <asp:DropDownList ID="ddlVehicles"
                            runat="server" 
                            DataTextField="strDescription" 
                            DataValueField="strCode" 
                            DataSource= <%# CodeLists.Vehicles() %> 
                            AppendDataBoundItems="true">
                            <asp:ListItem Text="" Value="" />
                        </asp:DropDownList>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Office:">
                    <InsertItemTemplate>
                        <Proj:OrgTree id="OrgTree" runat="server" Filter="false" Visible= <%# (AuthenticatedUser.CanCreateMis() != true) ? true : false %> 
                        SelectedValue =  <%# (AuthenticatedUser.IsCUS() != true) ? BaseControl.LoginOffice : Guid.Empty %>  />
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Customer Office:">
                    <InsertItemTemplate>
                        <Proj:OrgTree id="customerOrgTree" Filter="false" runat="server"
                        SelectedValue =  <%# (AuthenticatedUser.CanCreateMis() == true) ? BaseControl.LoginOffice : Guid.Empty %>  />
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Description:" ControlStyle-CssClass="Description">
                    <InsertItemTemplate>
                        <asp:TextBox runat="server" ID="txtDescription"
                            TextMode="multiLine" onKeyUp="Count(this,257)" onChnage="Count(this,257)"
                            Width="90%"/><br />
                            <div id="elCount"></div>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Procurement Type:">
                    <EditItemTemplate>
                        <asp:DropDownList ID="ddlProcurementTypeList" 
                            runat="server" 
                            DataTextField="strDescription" 
                            DataValueField="strCode" 
                            DataSource= <%# CodeLists.ProcurementTypes() %> 
                            AppendDataBoundItems="true">
                        </asp:DropDownList>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Type:">
                    <InsertItemTemplate>
                        <asp:DropDownList ID="ddlTypeList" 
                            runat="server" 
                            DataTextField="strDescription" 
                            DataValueField="strCode" 
                            DataSource= <%# CodeLists.Types() %> 
                            AppendDataBoundItems="true">
                            <asp:ListItem Text="" Value="" />
                        </asp:DropDownList>

                    </InsertItemTemplate>
                </asp:TemplateField>
            <asp:TemplateField HeaderText="Est Total Value:">
                <InsertItemTemplate>
                    <asp:TextBox ID="txtEstValue" 
                        runat="server"  />
                    <ajax:FilteredTextBoxExtender ID="FilteredTextBoxExtender1"
                        TargetControlID="txtEstValue"
                        FilterType="Numbers,Custom"
                        ValidChars=",."
                        runat="server" />                                                    
                </InsertItemTemplate>
            </asp:TemplateField> 
            <asp:TemplateField HeaderText="Customer Contact Date:">
                <EditItemTemplate>
                    <asp:TextBox ID="txtCustomerContact" 
                        runat="server"  />
                    <ajax:CalendarExtender ID="calCustomerContact" 
                        runat="server" 
                        TargetControlID="txtCustomerContact" />
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Req Start Date:">
                <EditItemTemplate>
                    <asp:TextBox ID="txtReqStartDate" 
                        runat="server" />
                    <ajax:CalendarExtender ID="calReqStartDate" 
                        runat="server" 
                        TargetControlID="txtReqStartDate" />
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Previous Number:">
                <EditItemTemplate>
                    <asp:DropDownList ID="ddlAwardList" 
                        runat="server" 
                        DataTextField="strAwardNumber" 
                        DataValueField="strAwardNumber" 
                        DataSource= <%# CodeLists.AwardNumbers() %> 
                        AppendDataBoundItems="true">
                        <asp:ListItem Text="None" Value="" />
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Currency">
                <EditItemTemplate>
                    <asp:DropDownList ID="ddlCurrencyList"
                        runat="server"
                        DataTextField="strCultureName"
                        DataValueField="strCulture"
                        DataSource= <%# CodeLists.Currency() %> 
                        AppendDataBoundItems="true" >
                        </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="?">
                <EditItemTemplate>
                    <asp:CheckBox runat="server" ID="chkMI" />
                    <div id="submitMIFields">
                        <Proj:MI runat="server" ID="initialMI" />
                    </div>
                </EditItemTemplate>
            </asp:TemplateField>
                <asp:CommandField InsertText="Submit" ShowCancelButton="False" 
                    ShowInsertButton="True" ControlStyle-CssClass="NewReqSubButton" />
            </Fields>
        </asp:DetailsView>

    </div>


    protected void Page_Load(object sender, EventArgs e)
{
    if (AuthenticatedUser.CanCreateMis())
    {
        CheckBox chkMI = (CheckBox)dvNewRequirement.FindControl("chkMI");
        chkMI.Checked = true;
        chkMI.Enabled = false;
        runjQueryCode();

    }
}

    private string getJQueryCode()
{
    StringBuilder sb = new StringBuilder();
    sb.AppendLine("$(document).ready(function() {");
    sb.AppendLine("$( #submitMIFields ).show();");
    sb.AppendLine(" });");

    return sb.ToString();

}

private void runjQueryCode()
{
    ScriptManager requestSM = ScriptManager.GetCurrent(Page);
    if (requestSM != null && requestSM.IsInAsyncPostBack)
    {
        ScriptManager.RegisterClientScriptBlock(this,
                                                typeof(Page),
                                                Guid.NewGuid().ToString(),
                                                getJQueryCode(),
                                                true);
    }
    else
    {
        Page.ClientScript.RegisterClientScriptBlock(typeof(Page),
                                                Guid.NewGuid().ToString(),
                                                getJQueryCode(),
                                                true);
    }
}
问题回答

我相信,为了加快网站的装饰,有一些非常容易的固定装置。

这确实取决于这一点,因为使用网络版业绩改进通常需要一个工作职位。 网络信息是减少和扩大最困难的网络框架之一。

典型的业绩改进可以通过下列方式实现:

  1. improving the query plan
  2. reduce remote calls (IO, DB, etc)
  3. reducing the amount of data loaded.

浏览器是带有网络格式的第1号性能杀手。 你们能够做的任何事情都是为了减少视力国家的规模。

如果你当时只显示几个记录,那么只记录你想要显示的记录。 数据库的数据,而不是数据调查。 当你装载100或1 000个记录,然后显示1-20个记录时,所检索的所有记录都储存在电文中,而不仅仅是向用户展示的记录。

提出询问的次数也会减少业绩。 你说有电网,如果你对电网进行约束,你就会把 look光值清单输入数据源控制下台。 每当数据来源受缩减名单约束时,数据来源就会执行。 创建elect n+1的问题就非常容易。

最后,如果问询结构不好,或 d虫没有优化(指数等),那么问询可能要第二次或甚至几分钟,而不是小秒。

Dig out a拷贝,Dynatrace AJAX edition (http://ajax.dynatrace.com/ajax/en/)

这种看法有多大,而这种脱硫的耗时多久?

有多少形式领域依靠的是观察国的数据,以及下降名单的大小。

我的猜测是,你把太多的数据推回,然后不得不通过 Java字进行脱射和人口化。

还有,你们使用什么样的浏览器,而且与目前的 Chrome或 Firefox子相比,这种浏览器是更快的。





相关问题
Dynamic creation of ASP.NET Form Elements

I m trying to build a form which generates itself as it is used. I have created a really simplistic example, loosely related to what I m trying to do below, but which demonstrates the problem. The ...

php Input field coming across as Integer

EDIT 2: After writing up an incredibly long explanation in more detail I, of course, discovered my problem and it had nothing to do with the question I asked. It was caused because I was creating a ...

IE7 onSubmit return false in function may fail?

I found this forum thread in google, but no one here seems to encounter the same problem, so I would like to know if onsubmit= return false; really fails in some IE7 browsers, meaning that it has ...

Required form field communication

I ve always communicated required form fields on web applications to users by hanging an asterisk off the end of the control or the label and having a little sentence along the lines of "required ...

WebForms and ASP.NET MVC co-existence

I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I ve done to make that happen is that I added a namespaces node to the WebForms web.config: <pages ...

Can the behaviour of new HTML5 form types be overridden?

I was wondering if anyone knew if it were possible to override the default behaviour of browsers that support the new HTML input types such as type="email" and type="date"? I appreciate that I could ...

热门标签