如何在CodeBehind中找到元素div? [英] How to Find Element div in CodeBehind ?

查看:96
本文介绍了如何在CodeBehind中找到元素div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在Code中找到控件div。使用.FindControl有没有办法在CodeBehind中访问它。





我的Div位于Repeater里面,我需要看到假的div



I'm unable to find the control div in Code behind using .FindControl Is there any way to Access it in CodeBehind.


My Div is Located inside Repeater and i need to visible false the div

<div id="divdlopt" runat="server" class="FileUploadDiv" style="display: none; width: 80%">
                                                                                                                            <asp:FileUpload ID="file" runat="server" size="10" CssClass="fileUploadControl" onchange="CopyMe(this, this.id)" />
                                                                                                                            <asp:TextBox ID="uploadFile" TabIndex="6" runat="server" Style="display: none;" CssClass="fileUploadTextbox"

                                                                                                                                Onclick="return img1(this,0)" onkeydown="return (event.keyCode == 9)" Width="7%"></asp:TextBox>
                                                                                                                        </div>

推荐答案

runat =server添加到您的div并找到它你通常这样做。请参阅:如何从C#处理id'ed DIV [ ^ ]
Add runat="server" to your div and find it as you normally do. See this : How to address id'ed DIV from C#[^]


请设置div的runat =server属性。
please set runat="server" property of div.


你可以使用foreach循环找到div 。



you can find div using foreach loop.

foreach(RepeaterItem item in Repeater1.Items)
{
    HtmlGenericControl divdlopt= item.FindControl("divdlopt") as HtmlGenericControl;
}


这篇关于如何在CodeBehind中找到元素div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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