繁体   English   中英

Repeater内的文本框未使UpdateProgress触发

[英]Textbox inside Repeater not making UpdateProgress to trigger

我在.aspx中有以下代码

<asp:UpdatePanel ID="upnGrid" runat="server" UpdateMode="Conditional">
                                    <ContentTemplate> 
            <asp:Repeater ID="rpt1" runat="server" OnItemDataBound="rpt1_ItemDataBound">
                <ItemTemplate>

                    <table width="100%">
                        <tr>
                            <td align="right" width="25%">
                                <asp:Label ID="lbl1" Font-Bold="true" Font-Size="16px" Text=' <%# DataBinder.Eval(Container.DataItem,"Name") %>'
                                    runat="server" />
                            </td>
                            <td>
                                <asp:HiddenField ID="hdn1" Value='<%# DataBinder.Eval(Container.DataItem, "Length") %>'
                                    runat="server" />
                            </td>
                            <td>
                                <asp:TextBox ID="txt1" Font-Size="16px" Text='<%# DataBinder.Eval(Container.DataItem, "Value") %>'
                                   AutoPostBack="true" Width="100px" OnTextChanged="txt1_TextChanged" runat="server" onkeydown="javascript:return OntxtEnter(event);"/>
                            </td>
                        </tr>
                    </table>

                </ItemTemplate>
            </asp:Repeater>
            </ContentTemplate>
                                    <%--<Triggers>
                                            <asp:AsyncPostBackTrigger ControlID="rpt1"/>
                                    </Triggers>--%>
                                    </asp:UpdatePanel>

UpdateProgress的代码位于aspx的末尾-

<asp:Panel ID="UpdateProgressPanel" runat="server">
    <center>
        <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="upnGrid"
            DynamicLayout="true">
            <ProgressTemplate>
                <img src="../Images/loading.gif" alt="">
            </ProgressTemplate>
        </asp:UpdateProgress>
    </center>
</asp:Panel>
<ajaxtoolkit:modalpopupextender id="ModalProgress" runat="server" targetcontrolid="UpdateProgressPanel"
    popupcontrolid="UpdateProgress2" dropshadow="false" backgroundcssclass="modalBackground">
</ajaxtoolkit:modalpopupextender>

根据一些答案的建议,我使AsyncPostBackTrigger在后面的代码中注册,例如-

var control = e.Item.FindControl("txt1");
ScriptManager.GetCurrent(Page).RegisterAsyncPostBackControl(control);

我不明白,为什么它不起作用。

请提出建议。

编辑

我尝试只在UpdatePanel中放置所需的文本框,它显示以下错误

'System.Web.UI.Control' does not contain a definition for 'DataItem' and no extension method 'DataItem' accepting a first argument of type 'System.Web.UI.Control' could be found (are you missing a using directive or an assembly reference?)

尝试如下所示修改您的UpdateProgress控件:

<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
    <ProgressTemplate>
        <asp:Panel ID="Panel1" runat="server">
                    <asp:Panel ID="Panel2" runat="server">
                        <asp:ImageButton ID="ibProgress" runat="server" ImageUrl="~/Images/progress.gif"
                            Visible="true" />Loading...
                    </asp:Panel>
        </asp:Panel>
    </ProgressTemplate>
</asp:UpdateProgress>

您不能以这种方式使用它。 因为在转发器内部,TextBox ID是不同的。您必须遵循不同的机制。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM