我的按钮点击事件需要很长时间才能响应

时间:2014-06-25 10:31:34

标签: c# asp.net-4.0

我只是按列方式创建一个网格视图搜索工具。 这是我的设计观点:

<asp:UpdatePanel ID="UpdatePanel7" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:Panel ID="Panel_Search" runat="server" Width="100px" DefaultButton="btnsearch">
<table>
<tr>
<td>
<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="DDL_Column_List" runat="server" 
AppendDataBoundItems="true" Width="120px" ValidationGroup="Search" 
onselectedindexchanged="DDL_Column_List_SelectedIndexChanged" 
AutoPostBack="True">
<asp:ListItem Value="-1">Select Column</asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
<Triggers>

<asp:AsyncPostBackTrigger ControlID="DDL_Column_List" 
EventName="SelectedIndexChanged" />

</Triggers>
</asp:UpdatePanel>
</td>
<td>&nbsp;</td>
<td><asp:TextBox ID="txtsearch" runat="server" CssClass="input" 
ValidationGroup="Search"></asp:TextBox>
<asp:RegularExpressionValidator id="RegularExpressionValidator3" runat="server" 
ValidationGroup="Search" 
SetFocusOnError="true" ControlToValidate="txtsearch" 
ValidationExpression="^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$" 
Display="None" Enabled="False"
ErrorMessage = "Publish date format should be like: DD/MM/yyyy"></asp:RegularExpressionValidator>
<asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender9" runat="server" 
TargetControlID="RegularExpressionValidator3" 
WarningIconImageUrl="~/images/Warning.gif" CloseImageUrl="~/images/close.gif" >
</asp:ValidatorCalloutExtender>
</td>
<td><asp:Button ID="btnsearch" runat="server" Text="Search" CssClass="btn-active" 
onclick="btnsearch_Click" ValidationGroup="Search" 
onclientclick="ClientSideClick(this);" UseSubmitBehavior="False"/></td>
</tr></table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>

这是我的代码:

protected void btnsearch_Click(object sender, EventArgs e)
{
    if (Page.IsValid)
    {
        if (DDL_Column_List.SelectedItem.Value != "-1" && txtsearch.Text.Trim() != "")
        {
            System.Threading.Thread.Sleep(2000);
            Session["SearchText"] = txtsearch.Text.Trim();
            switch (DDL_Column_List.SelectedItem.Text.ToString())
            {
                case "Title":
                    Session["ColumnName"] = "Title";
                    break;
                case "Publisher":
                    Session["ColumnName"] = "Publisher";
                    break;
                case "Publish Date":
                    Session["ColumnName"] = "PublishDate";
                    break;
                case "Category Name":
                    Session["ColumnName"] = "CategoryName";
                    break;
                case "File Size":
                    Session["ColumnName"] = "FileSize";
                    break;
                }
            }
            else
            {
                Session["SearchText"] = null;
                Session["ColumnName"] = null;
            }
            this.FillGrid(Session["CommandName"].ToString(), (String)Session["ColumnName"] ?? null, (String)Session["SearchText"] ?? null);
        }
    }
}

我只是提出了突破点,但它永远不会发生。当我将UseSubmitBehaviour设置为true时,它会在一些之后做出响应。锄头在我的项目的每一页都能正常工作。

请帮帮我....

0 个答案:

没有答案