So I am confused about creating nested templates, I need help!
OK so here is my site structed
Wrapper
Header
Container
left-column
Page_Content
Right_column
footer
(left-column, page-content, right column are inside container. Add everthing is inside wrapper)
OK so whats bugging me is that, left-column will have links like:
HTML
CSS
ASP
these will display on everypage unless I change it. So If someone clicks HTML,they will be redirected to HTML.cshtml. Now for the HTML.cshtml it will have its own template _HTML (_HTML, will be running from the MainLayout) However for the _HTML page, I do
not want the links:
HTML
CSS
ASP
I want links to do with HTML, e.g. Paragraphs etc. How can I change this, but keep the site layout same?
if you don't undertstand me, then this should help:
http://www.w3schools.com/
When you click on HTML, watch how the links on the left change to all HTML topics, but the design is still the same.
first, you can create a user control that accepts a value that identifies what links it should be showing. this value can be a data table that you can select from or just a service. pretty much everything that can identify your resources to show as links
in <asp:BulletedList DisplayMode="HyperLink">
two, you can create multiple user controls. each contain many links and then load the appropriate one dynamically by calling Page.LoadControl(@"myUC.ascx.cs") or Page.LoadControl(@"myUC.ascx.vb")
please remember to mark the helpful posts as answers. it will help other visitors to find their answers.
Lol I have done it in a much easier way. Tell me if this method is good:
I made the main template, and I put no content in the left column except
@RenderSection("left")
Then I made a new template, which runs of the main template, then in the new template I put:
@section left{
HTML
CSS
VB
}
then for the default page, I linked that to the new template I made. Then for the HTML pages, I made a new template (_HTML) made the @section left{} different and it worked! Rendered different content.
If you want to use the same layout page, but have content that might change, or not appear at all in that layout, sections is a good approach. User Controls as proposed by hj belong to web forms. They are not relevant to ASP.NET Web Pages.
If you want to use the same layout page, but have content that might change, or not appear at all in that layout, sections is a good approach. User Controls as proposed by hj belong to web forms. They are not relevant to ASP.NET Web Pages.
lol it's Mike Brind! I was actually reading your book, Beginning ASP.NET with Webmatrix, until I reached a dead end, Good Book though! learnt a lot from reading the first 3-4 chapters.
CriticalErro...
Member
423 Points
394 Posts
Confused with Nested Templates
Mar 25, 2012 09:04 PM|LINK
So I am confused about creating nested templates, I need help!
OK so here is my site structed
Wrapper
Header
Container
left-column
Page_Content
Right_column
footer
(left-column, page-content, right column are inside container. Add everthing is inside wrapper)
OK so whats bugging me is that, left-column will have links like:
HTML
CSS
ASP
these will display on everypage unless I change it. So If someone clicks HTML,they will be redirected to HTML.cshtml. Now for the HTML.cshtml it will have its own template _HTML (_HTML, will be running from the MainLayout) However for the _HTML page, I do not want the links:
HTML
CSS
ASP
I want links to do with HTML, e.g. Paragraphs etc. How can I change this, but keep the site layout same?
if you don't undertstand me, then this should help:
http://www.w3schools.com/
When you click on HTML, watch how the links on the left change to all HTML topics, but the design is still the same.
My Site | My Blog
hj
Contributor
2536 Points
552 Posts
Re: Confused with Nested Templates
Mar 25, 2012 09:18 PM|LINK
to do that you have two options:
first, you can create a user control that accepts a value that identifies what links it should be showing. this value can be a data table that you can select from or just a service. pretty much everything that can identify your resources to show as links in <asp:BulletedList DisplayMode="HyperLink">
two, you can create multiple user controls. each contain many links and then load the appropriate one dynamically by calling Page.LoadControl(@"myUC.ascx.cs") or Page.LoadControl(@"myUC.ascx.vb")
CriticalErro...
Member
423 Points
394 Posts
Re: Confused with Nested Templates
Mar 25, 2012 09:48 PM|LINK
Lol I have done it in a much easier way. Tell me if this method is good:
I made the main template, and I put no content in the left column except
@RenderSection("left")
Then I made a new template, which runs of the main template, then in the new template I put:
@section left{
HTML
CSS
VB
}
then for the default page, I linked that to the new template I made. Then for the HTML pages, I made a new template (_HTML) made the @section left{} different and it worked! Rendered different content.
My Site | My Blog
Mikesdotnett...
All-Star
154941 Points
19870 Posts
Moderator
MVP
Re: Confused with Nested Templates
Mar 26, 2012 04:54 AM|LINK
If you want to use the same layout page, but have content that might change, or not appear at all in that layout, sections is a good approach. User Controls as proposed by hj belong to web forms. They are not relevant to ASP.NET Web Pages.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
CriticalErro...
Member
423 Points
394 Posts
Re: Confused with Nested Templates
Mar 26, 2012 09:19 AM|LINK
lol it's Mike Brind! I was actually reading your book, Beginning ASP.NET with Webmatrix, until I reached a dead end, Good Book though! learnt a lot from reading the first 3-4 chapters.
My Site | My Blog