Link to home
Start Free TrialLog in
Avatar of TransBind
TransBind

asked on

set a value of literal in web user control referenced by master page and master page is referenced by WebPage

I have this set up
Master Page references Web User control, in Web User control there is a Literal
WebPage.aspx references Master Page. I would like to set a value of Literal in Web User Control in WebPage.aspx.cs file. I can do this in two ways and I would like to find out if there is a better approach.

Approach One:
I use Master Type to create a reference to Master Page in WebPage.aspx and in WebPage.aspx.cs file I use Master.FindControl("Literal").Text = value etc ...  The problem with this approach is FindControl, if in master page Web User Control is sitting inside of server elements than it would be a hard to reference it, and I would have to do it recursively.

Approach Two:
I can create a public property in Master Page Code behind which will reference a Literal from Web user control and in WebPage.aspx.cs I access the property and set a value of a Literal through a property.

Which Approach is Better and is there another approach where I can avoid creating a property?


 
ASKER CERTIFIED SOLUTION
Avatar of Praesidium
Praesidium
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial