Wednesday, March 28, 2012

Change dropdown selectedvalue in usercontrol, in a page.aspx

Hello,

i have a usercontrol (reservas.ascx) with one dropdown list (dropHoteis) inserted in one masterPage.
In my default.aspx, that is a content page of that masterPage...
How can i change the selected value in the dropdown list (dropHoteis) from my default.aspx?

1. In reservas.ascx, i put the Class Public...
2. In Default.aspx.vb, how can i reference the reservas.ascx?? I tryed, but not appear in my @dotnet.itags.org.Imports... why?

Thanks for your help!

From the page you can useMe.Master.FindControl("IdOfUserControl") which will get you the reference to your user control.

-Damien


Hep, ok...

But in my UserControl how can i declare the "function/property" to change the selectedValue of the dropdownlist??

Example:

Public Property DropSelectedValue(ByVal hotelAs String)Set(ByVal value) dropHoteis.SelectedValue = valueEnd Set Get dropHoteis.SelectedValue = hotelReturn dropHoteis.SelectedIndexEnd Get End Property

This not work for me!! :(

throw: Object reference not set to an instance of an object!!


in the usercontrol's code behind write a public property in which you have to set the dropdown list's value. u can then access that property from your page.aspx using the usercontrol name and can set the value of the dropdown list.

Regards & have a nice day ahead

No comments:

Post a Comment