I've a control that sits in the .aspx page, but the dynamic code is in separate project in Page.xaml.cs.
我有一个位于.aspx页面的控件,但动态代码位于Page.xaml.cs中的单独项目中。
On the same page as the control, I have:
在与控件相同的页面上,我有:
<asp:DropDownList ID="DropDownAppServer" runat="server" >
In the Page.xaml.cs I've tried doing this:
在Page.xaml.cs中我试过这样做:
HtmlElement element = doc.GetElementById( "DropDownAppServer" );
element.SetAttribute( "option", "blah" );
Didn't work. Although it works with:
没工作。虽然它适用于:
<input type="text" id="Text1" disabled="disabled" value="My Initial Value" />
2 个解决方案
#1
Could you elaborate as to why you are not doing
你能详细说明你为什么不这样做
DropDownAppServer.Option = blah?
You can use FindControl(ctrlName) functions to get references to children objects if you don't have explicit access to the control.
如果您没有对控件的显式访问权限,则可以使用FindControl(ctrlName)函数来获取对子对象的引用。
#2
I don't know anything about Silverlight, but coupling your controls together by name is very fragile.
我对Silverlight一无所知,但是通过名称将控件耦合在一起非常脆弱。
Is there a reason why you cannot pass a reference to the drop down to your control? Or even a reference to the page your control is on, which would allow you to use Page.FindControl(...).
您有没有理由不能将参考文献传递给您的控件?甚至是对控件所在页面的引用,这将允许您使用Page.FindControl(...)。
#1
Could you elaborate as to why you are not doing
你能详细说明你为什么不这样做
DropDownAppServer.Option = blah?
You can use FindControl(ctrlName) functions to get references to children objects if you don't have explicit access to the control.
如果您没有对控件的显式访问权限,则可以使用FindControl(ctrlName)函数来获取对子对象的引用。
#2
I don't know anything about Silverlight, but coupling your controls together by name is very fragile.
我对Silverlight一无所知,但是通过名称将控件耦合在一起非常脆弱。
Is there a reason why you cannot pass a reference to the drop down to your control? Or even a reference to the page your control is on, which would allow you to use Page.FindControl(...).
您有没有理由不能将参考文献传递给您的控件?甚至是对控件所在页面的引用,这将允许您使用Page.FindControl(...)。