简体   繁体   中英

Making a asp.net web site template without using master page?

I am very new to asp.net and my job.

I was assigned a project to make a simple online order web application using asp.net c#.

The specification has been strictly defined (copied below)

Regarding the common content of the site, I need to make head, top and left(a search function)

"The design in /design/: Head.aspx Top.aspx Left.aspx"

-- Does that mean I am not allowed to use (nested) master page?

--- If so, how can I make a template without using master page?

If the head/top/left content is just basic HTML, then you could just put the HTML in a separate file and use an include link/reference in the original .aspx page.

If the content is all like a search function, then I agree with Henk's comment, create an .ascx User Control (which is really no different than an .aspx page with an .ascx extension) and then just reference that control on your .aspx page like this:

//put this at the top of your .aspx page
<%@ Register src="usercontrols/YourControl.ascx" tagname="nameOfControl" tagprefix="ucControlName" %>

//then reference your control where you want it in your .aspx page
<ucControlName:nameOfControl ID="nameOfControl" runat="server" Visible="True" />

Here's an MSDN article on creating user controls: MSDN User Control

Maybe shoot the person who wrote the spec an email and ask why they have an issue with using a master page - this is kind of exactly why you would use one?!

JM

Another option is to use the Server.Execute() method to render the contents of three separate pages into your base page if you have to use pages instead of usercontrols and still must have three separate pages rendered into one.

In the old days we did this with iis html includes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM