Oi I seem to be having a few problems of late.
I am starting to use alot of user controls in my code, however I keep getting some odd errors. I am hoping one of you out there can help me out on this.
I am programmatically adding a user control to my page. The control enscapulates a searching function. The user enters some data and is given a list to pick from. Once the user picks the record they want, I set a variable that is available through a property. Now on a button event on the main page I want to grab that value.
The problem is that when the user activates the search button on the user control, the entire control no longer exists. I followed the debugger and the post back returns to the main page goes through the Page_Init and Page_Load Functions and that is it. The variable CustomerSearch1 is declared that the top of the page with the other variables
Protected WithEvents CustomerSearch1 As RoamingForestCaCe.CustomerSearch
I am adding the control in the page load with the following code.
If Not IsPostBack Then
CustomerSearch1 = LoadControl("UserControls/CustomerSearch.ascx"
CustomerSearch1.EnableViewState = True
Panel1.Controls.Add(CustomerSearch1)
End If
I also tried to simply drag the control onto the designer. Things worked perfectly then except when I went to grab the data from the controls property. I had declared a variable at the top along with the other server controls like so.
Protected WithEvents CustomerSearch1 As RoamingForestCaCe.CustomerSearch
It doesn't seem to mesh up at all though when I try to grab the data from the main page.
str &= CustomerSearch1.CustID I don't get the data out that was in that variable after I select it in the UC. Am I going to have to loop through the controls collection to get my control and manipulate it?
Bah! Home time talk to you folks tomorrow. That'l do donkey, that'l do
Mark
If you are unsure of forum etiquette check here faq796-2540
I am starting to use alot of user controls in my code, however I keep getting some odd errors. I am hoping one of you out there can help me out on this.
I am programmatically adding a user control to my page. The control enscapulates a searching function. The user enters some data and is given a list to pick from. Once the user picks the record they want, I set a variable that is available through a property. Now on a button event on the main page I want to grab that value.
The problem is that when the user activates the search button on the user control, the entire control no longer exists. I followed the debugger and the post back returns to the main page goes through the Page_Init and Page_Load Functions and that is it. The variable CustomerSearch1 is declared that the top of the page with the other variables
Protected WithEvents CustomerSearch1 As RoamingForestCaCe.CustomerSearch
I am adding the control in the page load with the following code.
If Not IsPostBack Then
CustomerSearch1 = LoadControl("UserControls/CustomerSearch.ascx"
CustomerSearch1.EnableViewState = True
Panel1.Controls.Add(CustomerSearch1)
End If
I also tried to simply drag the control onto the designer. Things worked perfectly then except when I went to grab the data from the controls property. I had declared a variable at the top along with the other server controls like so.
Protected WithEvents CustomerSearch1 As RoamingForestCaCe.CustomerSearch
It doesn't seem to mesh up at all though when I try to grab the data from the main page.
str &= CustomerSearch1.CustID I don't get the data out that was in that variable after I select it in the UC. Am I going to have to loop through the controls collection to get my control and manipulate it?
Bah! Home time talk to you folks tomorrow. That'l do donkey, that'l do
Mark
If you are unsure of forum etiquette check here faq796-2540