ModalPopupExtender无法识别TargetControlID [英] ModalPopupExtender doesn't recognize TargetControlID

查看:60
本文介绍了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.

推荐答案

在aspx页和添加的ModalPopup.show()后面的代码中为ModalPopUp添加了一个虚拟的隐藏字段.
Added a dummy hidden field for ModalPopUp in aspx page and in code behind added ModalPopup.show().

<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


如果模态位于网格之外,则它将无法识别该按钮,因为它看不到它.我的建议是将模态放入网格中,它将完美工作!
if the modal is outside the grid then it wont recognize the button because it cant see it. My advice is to put the modal inside the grid and it will work perfectly !


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

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