Get parent page values ​​from usercontrol

How to get parent page values ​​from usercontrol. I have user control on the page. When the usercontrols button is clicked, I want to get some values ​​from the page after the method is executed. I need these values ​​in my usercontrol. What is the best way to get page results in usercontrol.

+4
source share
3 answers

Raw Material: First property of the access page:

http://msdn.microsoft.com/en-us/library/system.web.ui.control.page.aspx

Next, you can apply the page property to the type of your page (regardless of whether it is) or you can use the Page.FindControl method to find page values ​​from other controls.

http://msdn.microsoft.com/en-us/library/31hxzsdw.aspx

In a good way, the user control should expose the event when this button was clicked, and the page should subscribe to this event and return data for control.

Is this what you are looking for?

+4
source

You can use the Page property to get a link to the page object. However, the link is not of the type of your particular page class, so you cannot use it to access specific members of the class without first launching it:

 MySpecificPageClass page = (MySpecificPageClass)Page; 

Now you can use the link to access any public members of the class. The controls on the page are often declared secure, so you may need to change their access level to access them from the outside.

+3
source

Source: https://habr.com/ru/post/1310335/


All Articles