How to set dropdown on .aspx page from managed code via DOM

I have a control that is on an .aspx page, but the dynamic code is in a separate project in the page.xaml.cs file.

On the same page as the control, I have:

<asp:DropDownList ID="DropDownAppServer" runat="server" >

      

In the page.xaml.cs file, I tried to do this:

HtmlElement element = doc.GetElementById( "DropDownAppServer" );
element.SetAttribute( "option", "blah" );

      

Does not work. Although it works with:

<input type="text" id="Text1" disabled="disabled" value="My Initial Value" />

      

0


source to share


2 answers


Could you please clarify why you don't

DropDownAppServer.Option = blah?

      



You can use the FindControl (ctrlName) functions to get references to child objects if you don't have explicit access to the control.

0


source


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



Is there any reason you can't pass a link to the dropdown? Or even a link to the page your control is on that will allow you to use Page.FindControl (...).

0


source







All Articles