I've just started learning ASP.Net but I've come across something that I don't know how it works. Say I have a "main page" that looks the same but depending on what GET value "page" says I should try loading a certain page without changing the main content. I have an index.aspx and whenever I goto index.aspx?page=login, it should try to load login.aspx.
Sure it works, but it writes out the ASP.Net code and not processing it. Not like PHP's include().
What I've tried is: Response.WriteFile() without no luck...
This is because, I have an index.aspx with an runat server id of Content and whatever the page I'm suppose to load is going to go there. So I don't have to recreate every page I make.
Any suggestions?
I think you should look at Master Pages. ASP.NET master pages allow you to create a consistent layout for the pages in your application.
A single master page defines the look and feel and standard behavior that you want for all of the pages (or a group of pages) in your application.
You can then create individual content pages that contain the content you want to display. When users request the content pages, they merge with the master page to produce output that combines the layout of the master page with the content from the content page.
ASP.NET Master Pages - MSDN
Related
I am working on a website using DNN as my Content Management System of choice, and I'm running into an issue where the main content area and the side area will switch based on which page you are on.
In the .ascx file I know I can write a conditional based on the URL you're on:
<% If Request.RawUrl.Contains("piece-of-url") Then %>
but I was wondering if there is a more permanent or reliable way to mark a page, just in case the page name changes, or if there are pages underneath that page that may not have the same styling (although, I can include the extension as a way to get around this).
Thanks for your help.
In DNN if you want to change the way the page functions, base on the page you are on, you would typically either define a separate SKIN as Brent Mannering suggests, or apply a differnt module to different pages on the site.
That being said, you can also target the "TabId" of DNN pages, in the code for the ASCX file for the Skin you could define functionality based on the tabid.
When I've needed to do this, I've created a 'Bookmark' module and added it on the page.The bookmark module just stores a value pair in the settings, in my instance I was using values like <"HotelHomePage", "Hilton"> or <"DestinationHomePage", "Sydney">. This way, page name doesn't matter, you can change the page name, move the page to a different parent, but as long as the bookmark value on the page stays the same, you will always have it.
Just make sure that a bookmark exists for each page you need it on.
A client of mine uses SharePoint to manage its websites, and recently asked me to build a small website for them using ASP.NET, which they would then implement via SharePoint.
My skills with ASP.NET are intermediate, and I have no experience at all with SharePoint.
I created a master page for the site, as well as the individual pages, but the client is telling me that they also need a page layout template in order to view and manage the site via SharePoint.
Unfortunately I have no idea what this means. So, my questions are:
What is the difference between a master page and a page template?
What does this page template look like? In other words, what type of file is it, and what kind of code goes in it?
Thanks in advance for any help you can provide!
The masterpage is what defines the design of your site. It applies for all pages within that site, except for the application pages which are shared by all SharePoint sites in the farm and use a different master page. You can recognize the application pages by looking at the url... it contains /_layouts/ (a virtual directory shared by all SharePoint sites).
When you create a new page in a MOSS site that has the publishing feature enabled, you are asked to specify a page layout. For example: 'Article page with image on right'. Each page layout is bound to one content type, in this example the content type 'Article'. Each content type can have multiple page layouts bound to it. You can have an article with the image on the right, with the image on the left or even without an image.
The content type is what defines the metadata for the page. An article for example, has a title, description, page image, article date,...
The page layouts are stored in the Master Page Gallery. You can create page layouts for existing content types, or you can create a new content type.
Basically, the master page defines how your site looks like, the page layouts define how your pages look like. One way (the easiest way) to create page layouts is to use SharePoint Designer which you can download for free from the Microsoft download pages.
You can find a lot of information about creating page layouts on the web. This may be a good starting point: http://office.microsoft.com/en-us/sharepoint-designer-help/create-a-publishing-page-layout-HA010174128.aspx
I have a main master page, say MasterPageMain, and a couple of folders with couple of pages in each folder which act as a child page to that master page - MasterPageMain.
Now, I have about 10 pages in one of the folder which follows a certain pattern and they could really use a nested pages since any change on some parts needs me to change all the pages which is a pain really.
I already added a Nested master page, say NestedMasterPage - which is a child of MasterPageMain
I tried to change one of the page's <%# Page directive to NestedMasterPage, immediately, there were a lot of errors. Plus I didn't know where the NestedMasterPage's children content would go.
What do I need to know in order to do this successfully?
Thanks!
P.S: I didn't do this initially because I only had 2 pages, and I didn't need this at that time, as the project grew, now I see that I should have changed it much earlier.
Also, a nested master page shifts the content regions the content pages define, so you probably have to clean that up, pointing the content region placeholders to the new content regions instead of the old one (swap the ID's)...
That could be a source of the error too, hard to tell without seeing the source.
In the sub master page add a reference to the main master page and then add specific content for the sub master page in the placeholder
<%# Master Language="C#" MasterPageFile="~/Parent.master"%>
Read up on it here nested master pages
I am converting an old html based website to ASP.NET, so that we can include more features like AJAX, Databases later on to the site. Currently my task is to create a new .aspx page for each older html page. To keep the layout persistent i have made a master page.
So currently i am building a content page from the master page, then renaming the content page and adding the text from the html page to the content placeholder area. However i was wondering if can cannot write a system, which can act as a Page Thrower.
Each hyperlink when clicked goes to a serverside code, where it requests the page it wants to load. Typically a webserver expects that the pagelink specified in the hyperlink does exist physically, but here what i am trying to do is that. Say the link is for the page "TravelDetails", the page need not exist physically, but the content of it is present in a file in (html format). so the Page Thrower gathers the data to display for that page, it has a master page already, it adds the html of it there and then throws the custom page. This way i don't have to keep 100+ aspx pages, i can do with a single page and maintain another data structure to store the content (static data) for each page. any guidance if my approach is right, and how to go about it?
Thanks
I think you should try some cms avaialable in market like dotnetnuke. Because every time you need to have to create a web page for a html page. In future if there will be any changes then it will take time. While in cms like dotnetnuke you just need to paste your html in existing system. You don't need to do coding again.
DotNetNuke is a free one. There are other Content Management System also available as well. Another advantage is that dotnetnuke is having skin features. So if you change skin at one place. You need not to do it for all the places.
Take a look at ASP.NET MVC. It uses ASP.NET Routing, which may help you.
Alternatively you can use ASP.NET Routing without MVC, too.
Matthias
Just a thought.
Create a page linked to the Master Page. In the content place holder add a Panel.
Let your Page thrower decide which page to display, retrieve the html data & add it to the panel at runtime.
Why don't you create the pages dynamically and then use asp.net caching in order to increase throughput.
I am not a designer, so I took a design template from http://www.opendesigns.org/ and was successful in implementing the design in one page, but when I tried to put it into a masterpage, it came out funny looking, so I was curious if there were any resources/tutorials on taking design templates and putting them in masterpages.
A master page is just HTML / ASP with a placeholder for the content.
As long as everything is well-formed, it should display as normal.
When I am building a master page, I build my design, then copy and paste into the master page and insert the placeholder where I need it.
some of what you say is quite confusing, i think you need to be clearer. A master page is a template for layout on your site or subsite, you would never serve a master page as content, you would always use the master page as a basis for a content page, the master page allows you to define a set of placeholders and, in principle, a global definition of the skeleton of your pages, for the area within which the master page will be used. Its usual to place site wide (or sub site wide - depends what you are doing) content onto the master page itself, things like menus, banners etc. And then let the pages that use the master page define what is held in the content placeholders that will be specific to the page instances.
when you say you put the design in a page, was it pure html ? or was it an aspx ? you arent clear on how you got from
1) design template to "page" (please explain html or aspx)
2) how you took your page and "put it in" your master page (i think if you explain, it might be easier to help)