eshurak
asked on
Set variable to object already on aspx page
Hello Experts,
I think this is an easy one. I need to set a variable to an object already my aspx. Here's my code it's called during the page_load event.
Thanks
I think this is an easy one. I need to set a variable to an object already my aspx. Here's my code it's called during the page_load event.
private void LoadSearchComboBoxs(string ComboName)
{
ComboBox TheComboBox;
TheComboBox = Page.Controls[ComboName];
}
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
...ged325's solution would require the same, for the same reason = )
ASKER
Kaufmed - Thanks for your input. I'm using:
ComboBox TheComboBox;
TheComboBox = (ComboBox)Page.Controls[Co mboName];
But I'm getting the following errors
The best overloaded method match for 'System.Web.UI.ControlColl ection.thi s[int]' has some invalid arguments
Argument '1': cannot convert from 'string' to 'int'
Is there a better way of doing declaring my object variable?
ComboBox TheComboBox;
TheComboBox = (ComboBox)Page.Controls[Co
But I'm getting the following errors
The best overloaded method match for 'System.Web.UI.ControlColl
Argument '1': cannot convert from 'string' to 'int'
Is there a better way of doing declaring my object variable?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm trying to use TheComboBox = (ComboBox)Page.FindControl (ComboName );
but it's also not working might be because I'm using a content page.
but it's also not working might be because I'm using a content page.
ASKER
Got it:
TheComboBox = (ComboBox)this.Master.Find Control("C ontentPlac eHolder1") .FindContr ol(ComboNa me);
TheComboBox = (ComboBox)this.Master.Find