Reputation: 13106
I have two web-form pages in ASP, one for viewing a record and and another for editing it. I would like to have a link on each which popups a box to allow editing a certain property on the record. If I only placed it on the Edit page, I would use an UpdatePanel but I would have to copy and paste code if I wanted it on the View page as well. Is there a way to have the code in one area which be can be referenced and used from both pages?
Edit: I know I could make a custom control to handle it although it would include all its HTML on the page when the page first loads, not when the link is clicked.
Edit2: I wanted to avoid having the contents of the popup rendered when the page first loads but now I realize it's just a matter of not binding any data in it until the Postback occurs.
Upvotes: 2
Views: 575
Reputation: 27492
Make the bulk of the panel a user control (ascx). Then just put a thin wrapper around it on both the pages where you need it. The bulk of the code is then in the ascx and ascx.vb and does not need to be written twice.
Upvotes: 1
Reputation: 1896
You can use a MasterPage for both the pages, and put the popup with UpdatePanel on the master page, so you can access it from both the pages.
Hope it helps. Don't forget to upvote it if it solves you problem. Thanks.. :)
Upvotes: 2