Reputation: 2107
I have two different ascx controls. They placed in the same folder. How can I call function in one file from another file if there are no namespaces specified?
Example of the file which contains a function I need to call.
public partial class atilektcms_cmsmoduls_security_security : StoreAwareUserControl
{
private void LoadUserEdit()
{
//function's actions
}
}
It is easy to see that here is no namespace declared. Can I declare a namespace for this file? How to do this correctly?
What also I need to do to make this function callable from another ascx.cs file? First of all I need to change the "private" to "public" I think. What's else?
Upvotes: 1
Views: 1654
Reputation: 33857
So what you want is a custom event on your 'child' control:
public event EventHandler SomethingHappened;
Which you are then going to raise (if handled) in your button click event within your child control:
protected void myButton_Click(object sender, EventArgs e)
{
if (SomethingHappened!= null)
{
this.SomethingHappened(this, EventArgs.Empty);
}
}
And you then need to handle this event within your parent control or page and react appropriately.
Upvotes: 2