S
Shapper
Hello,
I have a third party control in my page. I need to set the properties of
Labels and Images in this control when:
1. User enters the Page.
2. A button is clicked which changes culture (Change Properties)
Usually I would do it this way:
Sub Page_Load(...)
Set_Properties()
End Sub
Sub myMenu_MenuItemSelected(...) Handles myMenu.ItemSelected
Set_Properties()
End Sub
Sub Set_Properties() is:
Dim img As System.Web.UI.WebControls.Image =
myControl.FindControl("_ctl0").FindControl("imgLogo")
img.AlternateText = "New Text"
...
End Sub
Well, it doesn't work. I have this information:
"The control loads data and build object model in OnLoad event handler,
which occurs exactly after Page_Load event. The control objects can't be
accessed before or in Page_Load function.
This can be solved either using Page_Prerender function or any element
event handler for example Button_Click, etc., which occurs after
Page_Load event."
Well, with this info I made it work:
Private Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.PreRender
Dim img As System.Web.UI.WebControls.Image =
myControl.FindControl("_ctl0").FindControl("imgLogo")
img.AlternateText = "New Text"
...
End Sub
Sub myMenu_MenuItemSelected(.) Handles myMenu.ItemSelected
Dim img As System.Web.UI.WebControls.Image =
myControl.FindControl("_ctl0").FindControl("imgLogo")
img.AlternateText = "New Text"
...
End Sub
Well, even if it works I am duplicating my code which makes no sense to
me in terms of optimization.
Note: The duplicated code will be much longer that the one I show.
Can someone help me with this?
Am I following the wrong idea?
Thank You Very Much,
Miguel
I have a third party control in my page. I need to set the properties of
Labels and Images in this control when:
1. User enters the Page.
2. A button is clicked which changes culture (Change Properties)
Usually I would do it this way:
Sub Page_Load(...)
Set_Properties()
End Sub
Sub myMenu_MenuItemSelected(...) Handles myMenu.ItemSelected
Set_Properties()
End Sub
Sub Set_Properties() is:
Dim img As System.Web.UI.WebControls.Image =
myControl.FindControl("_ctl0").FindControl("imgLogo")
img.AlternateText = "New Text"
...
End Sub
Well, it doesn't work. I have this information:
"The control loads data and build object model in OnLoad event handler,
which occurs exactly after Page_Load event. The control objects can't be
accessed before or in Page_Load function.
This can be solved either using Page_Prerender function or any element
event handler for example Button_Click, etc., which occurs after
Page_Load event."
Well, with this info I made it work:
Private Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.PreRender
Dim img As System.Web.UI.WebControls.Image =
myControl.FindControl("_ctl0").FindControl("imgLogo")
img.AlternateText = "New Text"
...
End Sub
Sub myMenu_MenuItemSelected(.) Handles myMenu.ItemSelected
Dim img As System.Web.UI.WebControls.Image =
myControl.FindControl("_ctl0").FindControl("imgLogo")
img.AlternateText = "New Text"
...
End Sub
Well, even if it works I am duplicating my code which makes no sense to
me in terms of optimization.
Note: The duplicated code will be much longer that the one I show.
Can someone help me with this?
Am I following the wrong idea?
Thank You Very Much,
Miguel