Create master page at runtime - c#

Hi
I want to create a master page dynamically by the user like the one DotNetNuke is done
and load the modules where the user needs. I also want to have nested master pages with the above approach.
Please help me design the above problem.

Checkout:
Really Dynamic Master Pages
Nested Master Pages
Nested ASP.NET Master Pages

DotNetNuke has a very permissive open source license. You can use the Skin code from DNN in your own projects. Get the source here.

Related

Design Issue - Creating aspx pages dynamically

I currently have a web application that serves a single dashboard page. The client would like multiple dashboards for different systems displayed on the same physical machine. They would like to avoid installing many instances of the application as this would require opening up too many ports to view different dashboards.
They have suggested I alter my application to include multiple tabs/pages for each dashboard. Currently I have some C# classes which gather and process the data and feed it into the Default.aspx.cs file which then uses Web HTML controls to generate the html content and feed it into Default.aspx page via a placeholder.
At runtime I don't know how many Dashboards there will be or what they will be called (the C# classes read information from textfiles located in each dashboard directory on the drive, C:\Dashboard1*.txt C:\Dashboard2*.txt).
I am new to this and I'm struggling to see how to split the design out so that I can dynamically create the aspx.cs file and aspx file for each dashboard object.
Would a solution be to create a Dashboard.cs class that handles all the html generation (in place of default.aspx.cs) and creates an aspx page dynamically for each dashboard found on C:. Would all of the Web HTMLControls still work without a link between an aspx.cs file and a aspx file?
I realise this question is vague...more specifically I guess I am asking:
How do I create an aspx page dynamically from a C# class and then add web html controls to it? E.g. create the aspx page from a template and then use controls like HTMLGenericControl RowDiv = new HTMLGenericControl('div'). I wouldn't know how to link my C# class to the newly created aspx page so that the HTML Web controls knew they were supposed to be added to that new aspx page.
I would create the dashboard as an user control, and add the controls you need dynamically. Doing it like this you also have the option to create different looking dashboards (if you need it).

Common MVC _layout pages(Master page) for multiple websites

Is it possible to use a common layout page in MVC for multiple websites??
I have to use one layout page and i need to create multiple solutions of website and use the same layout page in all other websites
Try to use add existing item in visual studio add them as a link that way you will need to change only one file.

Implementing an html/css framework with a master page in visual studio

I'm working on a website for a school project and I designed it in photoshop with 9 columns.
To make life easier I want to use the 960 grid system (Custom for 9 columns) in order to build the design in html/css.
Part of the projects requirement is that I need to use a master page and web forms in c# however I'm not sure how to implement the 960 framework within that.
does anyone have any experience with this?
It sounds like you're being forced to use ASP.Net Web forms. I'd typically recommend you use ASP.Net MVC instead, and it does support Master pages, but really everything is a view, and I expect you would get push-back from the professor. So, to keep with the standard ASP.Net Web forms approach, you should create a new ASP.Net WebSite, and check off that you want a master page. Then Visual Studio will create the Master page for you, and any new aspx pages you create you can click a box to have them inherit from the master page.
If you look at the .Master page, you'll see the same HTML you would see on any site, including the , and tags. You should just include the .css file that contains your 960 framework file, just like you would on any Web page. Then the rest f the page will use the 960 grid, and you can put the necessary col# classes inside the class tag (or CssClass for ASP.Net controls) to get the display to work correctly.

What is equivalent to a php page setup in asp.net

I program php, but I am trying to get into c# asp.net. In php I can make forms, custom html, etc into a seperate php file and just include it on the page that I desire. I understand asp.net has a master page which allows you to set the template for the whole website, but what If I want just a row of buttons to be on SOME pages, and not all? something separate to the master page that can be included on any page i desire? Also when its controllers is that when I use .ascx?
Look at User Controls. You can program a control that consists of a row of buttons and then put it on whichever pages you like.
There are two different approaches to ASP.NET nowadays.
ASP.NET WebForms:
Each page (.aspx) can have a Master Page (.master). Each master page can further have its own master page. Master pages are optional altogether, but if present, at least one in the heirarchy will typically have the opening and closing html, head, body, and form tags.
Each page (and master pages too) can reuse html/logic within itself through Web User Controls (.ascx), for instance if you wanted to create a reusable comment box "control".
ASP.NET MVC:
Each View can have a master layout.
Each View or master layout can trigger the rendering of child/partial Views, for further reuse of html/logic.
Nowadays, if coming from PHP, I'd learn ASP.NET MVC instead of WebForms if I were you.
As DuckMasetro. Said, we can have master Page Concept. It Is easiest way to do.. You can Design master pages in Designer mode with liitle efforts. then Just Use MasterPageFile="url" this property in your Webforms Page Directive at the top of your aspx. page
Tutorials for Begginers
Documentation for Master Page in ASP.net

.Net include page - like php require

Is there a c# command to include another web page - the equivelant of the php require?
I know how to do server side includes but was looking for something code based.
Thanks
Thanks for the answers all. I think I might need to explain further. I have several sub-pages that I will be loading during the use of the site using an xmlhttp request. Initially however, I need to load the starting sub-page before the user has interacted with the site. I could do this with js, but that would require more overhead in server calls from the client for the initial load. I already use master pages, but this is a little different. Since this is done serverside initally but must remain able to be refreshed clientside, I don't think I can make these pages into controls can I? I am pretty new to .Net so I may be making my life harder than I need to.
I think what you may be looking for are MasterPages and UserControls. A MasterPage allows you to define a basic template that is "filled in" by the implementing pages by having the implementing page add it's own content to the ContentPlaceHolders defined on the MasterPage. A UserControl is a re-usable piece of markup and associated code that you can reference from your mark up or add dynamically to the page being rendered in codebehind.
The way ASP.NET is structured, you shouldn't really need to do this. Code is compiled, so all of your classes and functions should be accessible simply by referencing the relevant assembly or namespace, without having to include individual code files.
You might be looking for user controls, which allow you to create fragments of markup with their corresponding code behind, and then reference these in your page.
With ASP.NET MVC it looks like this:
<% Html.RenderPartial("LogOnUserControl"); %>
This way you can put another UserControl on your page.
you can use include in asp.net like php include from below mentioned code
<!--#include file="include/leftmenuscript.inc"-->
You can also use a master page, as someone stated below, which flushes out your basic layout and lets you define content place holders, which other pages can implement and fill in the content. Master pages are a popular approach for defining page elements that are consistent across all pages, like your nav there (also things like headers, footers, common scripts, CSS, etc.).

Categories

Resources