本文介绍了ModalPopupExtender无法识别TargetControlID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

调用GridView Item模板中的按钮ID时出现错误.

错误:"mpueResend"的TargetControlID无效.找不到ID为"btnResend"的控件."

代码:

I am getting an error when i call the button id which is inside GridView Item template.

Error: "The TargetControlID of ''mpueResend'' is not valid. A control with ID ''btnResend'' could not be found."

Code:

<asp:GridView ID="GridMultiD" runat="server" CellPadding="3" 
                        AlternatingRowStyle-BackColor="#EDF3F7" HeaderStyle-CssClass="gridbgheading" 
                        Width="100%" HeaderStyle-HorizontalAlign="Center" >
                        
                    
                    <Columns>
                        <asp:TemplateField HeaderText="Resend">
                            <ItemStyle HorizontalAlign="Center" />
                                <ItemTemplate>
                                    <asp:Button ID="btnResend" runat="server" Text="Resend" CssClass="text ButtonInline"  />
                                </ItemTemplate>
                        </asp:TemplateField>
                        </Columns>
                        
                    </asp:GridView>





<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:ModalPopupExtender ID="mpueResend" runat="server" TargetControlID="btnResend" PopupControlID="pnlPopupResend" 
        BackgroundCssClass="modalBackGround" DropShadow="true" CancelControlID="btnCancelR" >
    </asp:ModalPopupExtender>



请让我知道是否有解决方案.

谢谢.



Please let me know if there is any solution for this.

Thank You.

推荐答案

<asp:HiddenField ID="hfHidden" runat="server />
<asp:ModalPopupExtender ID="mpueResend" runat="server" TargetControlID="hfHidden" PopupControlID="pnlPopupResend" 
        BackgroundCssClass="modalBackGround" DropShadow="true" CancelControlID="btnCancelR" />

<asp:GridView ID="GridMultiD" runat="server" CellPadding="3" AlternatingRowStyle-BackColor="#EDF3F7" HeaderStyle-CssClass="gridbgheading" Width="100%" HeaderStyle-HorizontalAlign="Center" OnRowCommand="GridMultiD_RowCommand">  
    <Columns>
        <asp:TemplateField HeaderText="Resend">
            <ItemStyle HorizontalAlign="Center" />
            <ItemTemplate>
                 <asp:Button ID="btnResend" runat="server" Text="Resend" CssClass="text ButtonInline"  CommandName="ViewComments" />
            </ItemTemplate>
        </asp:TemplateField>
    </Columns> 
</asp:GridView>





protected void GridMultiD_RowCommand(object sender, GridViewCommandEventArgs e)
{
    switch (e.CommandName) // check the incoming command name
    {
        case "ViewComments":
            mpueResend.Show();
            break;
    }        
}



谢谢



Thank You



这篇关于ModalPopupExtender无法识别TargetControlID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 20:06