views:

431

answers:

2

I've a control that sits in the .aspx page, but the dynamic code is in separate project in 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:

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" />
A: 

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.

Alan Jackson
I can't do DropDownAppServer.Option = blah?because this is a silverlight control, that is being instantiated in the a separate project in a .aspx page. The drop down itself is in the .aspx page with that silverlight control.
ra170
A: 

I don't know anything about Silverlight, but coupling your controls together by name is very fragile.

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(...).

Jason Berkan