简体   繁体   中英

How to call a button click of another aspx page in code behind?

How to call Button.Click of one Page from another Page , both pages are open. Second page is a ClientScript.RegisterStartupScript popup from the first page.

When I click button in second page, the ClientScript popup should close and also it should fire Button.Click event in First Page.

Not possible that easy. You can't call an event handler on another page's controls, and it sounds like a terrible design in my opinion.

I would suggest to move the contents of that event handler to another class, separate from the pages' code behind files and call it from the page you are in.

Other options could include javascript solutions, but you clearly statement you don't want to use those. Else, this could be a solution to close the window. For calling the event handler on 'page 1' you could do a postback.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM