用母版页找到html控件 [英] find html control with master page

查看:82
本文介绍了用母版页找到html控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的应用中找到HTML TextArea控件.
我正在使用母版页,我想找到位于下一页的控件

我尝试过:


I am trying to locate an HTML TextArea control from my app.
i m using a master page and i want to find the control located in conext page

I''ve tried:


Dim htaDemo As HtmlTextArea = DirectCast(Me.FindControl("TextArea1"), HtmlTextArea)(as  my button is also in the context page)



其中Content1是ContentPlaceholder的名称,TA1是分配给HTML文本区域的ID,但是我只是收到对象引用错误.
香港专业教育学院尝试Page.FindControl(),Page.Master.FindControl(),this.FindControl()和只是findControl.
任何人都可以协助我从背后的代码中引用计划html文本区域.我只有runat = server,因为我应用了一些客户端javascript,而当我这样做时,javascript无法运行,因此我需要找到客户端控件.
谁能帮我吗???谢谢n先进....



Where Content1 is the name of the ContentPlaceholder and TA1 is the ID assigned to the Html textarea, but I just get a object reference error.
Ive tried Page.FindControl(), Page.Master.FindControl(), this.FindControl() and just findControl.
Can anyone assist in how I reference a plan html textarea from the codebehind. I have just the runat=server because im applying some client-side javascript which doesn’t function when I do that, so I need to find the client control.
can anyone help me out??? thanks n advance....

推荐答案

您的问题是FindControl()方法仅在直接子控件中显示.
如果您的TextArea层次结构更深,则找不到它.
在这种情况下,您需要创建将遍历整个控制树的递归方法.
Your problem is that FindControl() method looks only in direct child controls.
If your TextArea is deeper in hierarchy it will not find it.
In that case you need to make recursive method that will search through entire control tree.


这篇关于用母版页找到html控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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