Riti
Riti

Reputation: 39

Asp.net access method from user control access method

I've a user control registered in an aspx page On click event of a button in the aspx page, how do i call a method which is there in the user control? I need to execute the method in user control on click event of button in aspx page.

Thanks....

Upvotes: 0

Views: 873

Answers (1)

Saurabh
Saurabh

Reputation: 5727

// Below might help

UserControl B = new UserControl();
Object[] parameters = new Object[2];
parameters[0] = 45;
parameters[1] = "test"; 
B = (UserControl)Page.FindControl("[UserControlId]");
B.GetType().GetMethod("[MethodName]").Invoke(B, parameters);

Upvotes: 2

Related Questions