Question

I'm building custom .NET web user control for Umbraco, which looks like single page, with a sidebar (which holds IDs of content items) on the left side of page, and two different content views(which have content by id displayed here) to the right of it.

The thing is, i don't know if this is possible to do something like masterpage/childs principle(in terms of this web user control), so i'll have something like "Master page" with this sidebar, and will render one of two child views to the right of it, depending on id selected from sidebar?

Or maybe there should be some workaround used here? Will be much appreciated on any help here(like information about how that can be done, what information shall i seek for etc.), as i'm completely new in this kind of stuff.

Was it helpful?

Solution

From what I know, what you could possibly do is have your "master control" set up in your web user control, and then dynamically create one of two custom controls based on the values you choose from your master control. This is also known as a Master-Detail solution (provided a link).

Tutorial 10: Master/Detail Using a Selectable Master GridView with a Details DetailView

If each of these controls was a user control in itself nested inside another user control, you could for example have three web user controls: Master, Child1 and Child2.

Using code-behind, you could easily create dynamic controls based on those you select from your Master control using Events to the "container page". Using these events, you could dynamically create your user controls/pass them variables, and so on.

Here are some articles about events, if you are interested:

Events in User Controls

Events in ASP.NET Server Controls

If you didn't want to dynamically create your controls, it wouldn't be difficult to bind them on demand dependent on the variable from your Master control, and hide them if they are not being used/bound.

You could also use the public properties of a control you define yourself. So say you have your Child1 user control, you could define a public property in the code behind. You can access this in design-time as well.

public int SpecialID { get; set; }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top