FindControl需要解释! [英] FindControl needs an explaination!
问题描述
我正在使用FindControl来访问动态加载的用户控件。我确定我已经完全错了,因为我是.NET的新手。
目前我想在用户控件中访问按钮或查看模式嵌套在嵌套在母版页中的页面中。我必须使用此方法来查找控件。
Hi,
I am using FindControl to access dynamically loaded user controls. I''m sure I''ve got it all wrong as I''m new to .NET.
Currently if I want to access a button or view mode in a user control nested in a page nested in a master page. I have to use this method to find the control.
推荐答案
HI再次,
我的意思是有一种方法可以在类后面的代码中分配一个ID来引用深入页面的控件吗?
再次感谢。
HI Again,
What I mean is there a way of assigning an ID in the code behind class to reference controls that are layered deep into the page?
Thanks again.
HI再次,
我的意思是有办法在类后面的代码中分配ID以引用深入p的控件年龄?
再次感谢。
HI Again,
What I mean is there a way of assigning an ID in the code behind class to reference controls that are layered deep into the page?
Thanks again.
在其他东西下埋葬的控件需要像你埋葬它一样被捕获
FormView viewFC1 =(FormView )this.FindControl(" UpdatePanelFC")。FindCo ntrol(" DetailsViewFC1");
我认为UpdatePanelFc不是动态创建的控件
>
你可以使用
Controls burried under somthing else will need to be fished out the same way you burried them
FormView viewFC1 = (FormView)this.FindControl("UpdatePanelFC").FindCo ntrol("DetailsViewFC1");
from that I presume UpdatePanelFc is not a dynamically created control
you can shorten that piece of code using by
感谢您回复Shashi。
我正在使用一个BasePage类我的方法/事件处理程序等的st。因为它们被许多不同的用户控件使用。用户控件在构建页面时动态加载到页面中。当我加载每个控件时,我已设法为它们分配ID。
当我尝试访问已动态加载的用户控件内的updatepanels内的控件时,我的无知开始显示。我知道有一个控件集合但是当我尝试递归查看集合以找到控件时我会收到错误。
我遇到的第二个问题是我已经设置了updatepanels在每个控件里面有条件。我希望在一个用户控件中的事件触发所有updatepanel中的更新。但是这些更新面板位于页面上随机定位的用户控件内。
我需要找到一种方法来访问控件和updatepanel而不使用长串FindControl。
任何指向正确方向的小例子都会受到赞赏。
Thanks for responding Shashi.
I am using a BasePage class for most of my methods/event handlers etc. Because they are used by lots of different user controls. The user controls are loaded into the page dynamically when they page is built. I have managed to assign them IDs when I load each control.
My ignorance starts to show when I am trying to access controls inside updatepanels inside user controls that have been dynamically loaded. I know there is a Controls Collection but when I try to recursively look through the collection to find a control I get errors.
The second problem I am having is that I have set my updatepanels inside each control to conditional. I want to an event in one user control to trigger an update in all the updatepanels. But these updatepanels are inside user controls that are positioned randomly on the page.
I need to find a way to access controls and updatepanels without using long strings of FindControl.
Any small examples to point me in the right direction would be appreciated.
控制权在其他方面被埋没将需要像你埋葬它们一样被捕获
FormView viewFC1 =(FormView)this.FindControl(" UpdatePanelFC")。FindCo ntrol(" DetailsViewFC1"); <我认为
我认为UpdatePanelFc不是动态创建的控件
你可以使用
Controls burried under somthing else will need to be fished out the same way you burried them
FormView viewFC1 = (FormView)this.FindControl("UpdatePanelFC").FindCo ntrol("DetailsViewFC1");
from that I presume UpdatePanelFc is not a dynamically created control
you can shorten that piece of code using by
这篇关于FindControl需要解释!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!