tags:

views:

17

answers:

1

I have a property on a page called

public string productName { get; set;  }

I want to access this in my usercontrol code behind. What's the right way to do it?

Currently I am doing

((MyPage)Page).productName

But the user control is not compiling. My pagename is MyPage and I have also added a Reference

<%@ Reference VirtualPath="~/MyPage.aspx" %>
A: 

What is the error message? Actually it should work the way you want it to have, if you include your control correctly into the page's lifecycle, e.g. if you create an instance in the markup.

Nevertheless you should think about why your control should need to access a property of the current page. In my opinion it would be besser to assign the property to your usercontrol and retrieve the value from there

citronas