AsyncPostBackTrigger禁用按钮 [英] AsyncPostBackTrigger disables buttons

查看:156
本文介绍了AsyncPostBackTrigger禁用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的UpdatePanel,并在它之外的按钮。我介绍的按钮在UpdatePanel中的AsyncPostBackTrigger。 UpdatePanel的本身工作正常,但按钮不会。只要单击该按钮,它的点击处理程序不运行就像按钮没有点击了!

为什么按钮没有工作,怎么能解决吗?


更新: 这里是标记:

 < ASP:UpdatePanel的ID =upGridView=服务器的UpdateMode =条件>
            <的ContentTemplate>
                < ASP:GridView控件ID =grdListSkinID =SimpleGridViewDataKeyNames =键=服务器
                    AllowPaging =真,每页=15的AutoGenerateColumns =FALSE标题=<%$资源:CommonResources,grdListCaption%>中
                    EmptyDataText =<%$资源:CommonResources,grdListEmptyDataText%>中OnRowEditing =grdList_RowEditing
                    OnPageIndexChanging =grdList_PageIndexChangingOnRowCreated =grdList_RowCreated>
                    <列>

                    < /列>
                < / ASP:GridView控件>
            < /的ContentTemplate>
            <触发器>
                < ASP:AsyncPostBackTrigger控件ID =btnDelete事件名称=点击/>
                < ASP:AsyncPostBackTrigger控件ID =btnN​​ew事件名称=点击/>
                < ASP:AsyncPostBackTrigger控件ID =btnForward事件名称=点击/>
            < /触发器>
        < / ASP:UpdatePanel的>

        < ASP:按钮的ID =btnDelete=服务器SkinID =按钮文本=<%$资源:CommonResources,btnDelete%>中
            的OnClick =btnDelete_Click/>
        < ASP:按钮的ID =btnN​​ew=服务器SkinID =按钮文本=<%$资源:CommonResources,btnNew%>中
            的OnClick =btnN​​ew_Click/>
        < ASP:按钮的ID =btnForward=服务器SkinID =按钮元:的ResourceKey =btnForward
            的OnClick =btnForward_Click/>
 

解决方案

作为其清晰的页面(模块)不成才的Page_Load事件,这事件prevent potbacking您的按钮。

我的意思是你尝试后回来,Page_Load事件再次运行,一切都显示为第一次,

我有这个problemt和resolveit通过将一个

 如果(!的IsPostBack)
      做一点事();
 

I've a simple UpdatePanel and a button outside of it. I've introduced the button as an AsyncPostBackTrigger in the UpdatePanel. UpdatePanel itself works fine but the button does not. Whenever the button is clicked, its click handler does not run just like the button is not clicked at all!

Why the button is not working and how can it be fixed?


UPDATE: here is the markup:

            <asp:UpdatePanel ID="upGridView" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:GridView ID="grdList" SkinID="SimpleGridView" DataKeyNames="Key" runat="server"
                    AllowPaging="True" PageSize="15" AutoGenerateColumns="False" Caption="<%$ Resources: CommonResources, grdListCaption %>"
                    EmptyDataText="<%$ Resources: CommonResources, grdListEmptyDataText %>" OnRowEditing="grdList_RowEditing"
                    OnPageIndexChanging="grdList_PageIndexChanging" OnRowCreated="grdList_RowCreated">
                    <Columns>

                    </Columns>
                </asp:GridView>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnDelete" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="btnNew" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="btnForward" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>

        <asp:Button ID="btnDelete" runat="server" SkinID="Button" Text="<%$ Resources: CommonResources, btnDelete %>"
            OnClick="btnDelete_Click" />
        <asp:Button ID="btnNew" runat="server" SkinID="Button" Text="<%$ Resources: CommonResources, btnNew %>"
            OnClick="btnNew_Click" />
        <asp:Button ID="btnForward" runat="server" SkinID="Button" meta:resourcekey="btnForward"
            OnClick="btnForward_Click" />

解决方案

as its clear your Page (Module) does someting in Page_Load event and this event prevent potbacking your button.

I mean You try to post back, and Page_Load event run again and everything appear as the first time,

I had this problemt and resolveit by putting a

  if(!IsPostBack)
      DoSomething();

这篇关于AsyncPostBackTrigger禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆