Updating UserControl with dynamically generated fields
Posted on 2010-09-17
I have a user control which based on 2 properties generates different TextBox entry fields at run time.
There is code in the Page_Init that will take the 2 property values and return the appropriate TextBoxes that should be generated from a database.
When I hard code the property values of the control on the aspx page it generates the correct TextBoxes.
<uc:SupplementalInfoControl ID="supCtrl" runat="server" Master_Id="1" OS_Typ_Id="22"></uc:SupplementalInfoControl>
But when I try to set the properties at runtime I cannot get it to work correctly. I've tried setting the properties by supCtrl.Master_Id = 1; and supCtrl.OS_Typ_Id = 22; I've also tried using binding so:
<uc:SupplementalInfoControl ID="supCtrl" runat="server" Master_Id="<%#GetMasterId() %>" OS_Typ_Id="<%#GetOSTypId() %>"></uc:SupplementalInfoControl>
Where GetMasterId() and GetOSTypId() are pubic methods that return the respective values.
I'm trying to use this control inside of a tab container, I'm able to get it to work if I put it in a popup window and use session variables but I would like to avoid that if possible. Any help would be appreciated.
Thanks in advance.