J
Jonah Olsson
Hello guys,
I have an application which is built upon several user controls. That is, I
have a default template (default.aspx) that I load a user control into
(using placeholders in the template).
Now, the template also contains a placeholder for buttons used by each user
control. The current solution needs each user control to create its buttons,
like;
Dim button As New Button
button.Text = "buttontext"
button.CssClass = "button"
button.ID = "button_id"
CType(Page.FindControl("buttonHolder"),
PlaceHolder).Controls.Add(button)
AddHandler button.Click, AddressOf button_click
But instead I would like a more sophisticated method to simplify this and
reduce code. Maybe using classes? I would like to just call a function like;
CreateButton(buttonTitle As String, buttonId As String, addOnClickHandler As
String)
This function would also create AddHandlers and all that I currently need to
add within each user control "by hand".
Since the button placeholder mostly contains more than one button for each
user control, maybe CreateButton should add the button to a array and then
add that one to the placeholder through another function?
Has anyone any experience in this? I'm very thankful for any feedback or
ideas..
Thanks.
Regards,
Jonah Olsson
I have an application which is built upon several user controls. That is, I
have a default template (default.aspx) that I load a user control into
(using placeholders in the template).
Now, the template also contains a placeholder for buttons used by each user
control. The current solution needs each user control to create its buttons,
like;
Dim button As New Button
button.Text = "buttontext"
button.CssClass = "button"
button.ID = "button_id"
CType(Page.FindControl("buttonHolder"),
PlaceHolder).Controls.Add(button)
AddHandler button.Click, AddressOf button_click
But instead I would like a more sophisticated method to simplify this and
reduce code. Maybe using classes? I would like to just call a function like;
CreateButton(buttonTitle As String, buttonId As String, addOnClickHandler As
String)
This function would also create AddHandlers and all that I currently need to
add within each user control "by hand".
Since the button placeholder mostly contains more than one button for each
user control, maybe CreateButton should add the button to a array and then
add that one to the placeholder through another function?
Has anyone any experience in this? I'm very thankful for any feedback or
ideas..
Thanks.
Regards,
Jonah Olsson