Visual studio templating system [closed]
-
05-06-2021 - |
Question
I am doing web development in ASP.NET.
Is there some way to load different page designs depending on who lands on your page.
So I want to create a sort of template system where I offer a selection of templates for a page and the user selects what one they want.
Is there some built in functionality for this or is there any plug-ins I can use?
Thanks
Solution
There's the built in ASP.NET functionality called "theming"
Here's a tutorial on MSDN:
OTHER TIPS
Are you wanting to change the ASP.NET site template or the stylesheet? If it's the latter, let's say your main stylesheet is embedded like so:
<link rel="stylesheet" type="text/css" href="Styles/Site.css" />
Add an ID to the tag, such as id="style". Then in the code-behind you could do the following (I've used a button in this example but perhaps a DropDownList control would be the best, which you could populate with stylesheets found in a certain directory):
protected void BtnStyle_Click(object sender, EventArgs e)
{
HtmlLink Link = FindControl("style") as HtmlLink;
if (Link.Href.Equals("Styles/Site.css"))
Link.Href = "Styles/Site2.css";
else
Link.Href = "Styles/Site.css";
}
As for changing the site template programmatically, I have no experience, but I imagine that it's possible.