我有一个网页,使用户能够将信息输入形式。 我在网页上和后面的代码上都使用一些 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);
}
}