I have a User Control ContactUC
, with a button PageButton
.
public Button PageButton
{
get { return this.ProjectManagerOperation; }
set { this.ProjectManagerOperation = value; }
}
I want to use this button in another page called AdminPage
I have put this code into the AdminPage.aspx.cs
<%@ Register Src="~/ContactUC.ascx" TagPrefix="uc1" TagName="ContactUC" %>
to access the User Control ContactUC
.
Then in the AdminPage
, I do :
ContactUC c = new ContactUC();
Now I want to access the button action when the user clicked it.
Instead of accessing button, why not move whatever button does to some public void method :
public void SomeButtonClick()
{
//Do magic
}
and then you can access it like that
ContactUC c = new ContactUC();
c.SomeButtonClick();
or in some cases
ContactUC.SomeButtonClick();
might work as well
Unless there's some reason you want to access actual UI element and not the action it does (even if there's almost never reason to do that).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.