Leon Friesema said:
I have a user control which contains a button. In the btn click event
handler I need to call a funtion in the parent aspx page, but not sure
how
to do it.
TIA,
Steve
(([ParentObjectType])this.Parent).[Funtion]([Parameters]);
With the parentobjecttype you cast the object "parent" to the
objecttype from your parent. After that you can call any public method
in the class.
Leon.
Thanks, but am a bit lost. Here this Event Handler:
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click
' Call the aspx funtion ok()
End Sub
Here is a snipped from the aspx page.
Public Sub OK() Handles ucManageButtons.Load with events
lblMessage.Text = "Test OK"
End Sub
I am not sure how to code this???
TIA,
Steve
Wow.. VB.NET, I answered in C# syntax, no wonder you got lost.. Well
some digging in the MSDN brought up the CType-method, so let's take it
from there.
Furthermore: you're mixing up 2 things; eventhandling and
method-calling; You state Sub Ok is handling events from the
UserControl, which it isn't, it's just method;
Let's say your parent page, containing the control is named
"ParentPage.aspx", with that your class name would be "ParentPage",
so..
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click
CType(Me.Parent, ParentPage).Ok()
End Sub
Here is a snipped from the aspx page.
Public Sub OK()
' --> FORGET THIS: Handles ucManageButtons.Load with events
lblMessage.Text = "Test OK"
End Sub
Leon.