开发者

How do I setup a Master Page with ASP.net?

I'm normally a ColdFusion developer, but I'm having to work on a new site using some ASP.net hosting only, so forgive me if my questions seem very trivial.

For numerous reasons, the website will be relatively static in the sense that it will mainly be using includes etc...that's about as complex as it will get with this.

Now, I heard about the ability to set a master in ASP.net. Would anyone please be able to explain to me in a step process on how to do this? I have of course been searching for so开发者_如何学Cme time now on this topic but most results yield little help or no help at all since the search terms are slightly ambiguous.

It would be nice to have this functionality for the long run. Any help or advice would be great.

Many thanks. Michael.


Here's a great walkthrough video on creating and using Master pages in ASP.NET.

Basically, the steps are:

  • Add a Master page to your ASP.NET project. This is the same for webforms and ASP.NET MVC
  • Style it as you like. This is where most of your <head> content will be... CSS, JavaScript, etc. The key steps are to have ContentPlaceHolders. Those areas around the CPH will be static, and not change.
  • Add a new Content page. You'll then choose the Master to inherit from.
  • Add content to the Content page as you like. You'll see (in Design View) that the Master's look and feel will be uneditable. In Source view, you'll only be able to specify the content that will go into the Master's ContentPlaceHolders.

It'll be much easier to fit into the .NET ecosystem and all the built in features. Try it free -- download Visual Web Developer Express. Using other editors would waste an order of magnitude of your time! The install takes maybe 4 mins. There's no wizard here, it's just a File->New Document scenario.


The second section on this page (http://www.asp.net/web-forms/fundamentals/) has 10 links to various tutorials about masterpages.


Here's yet another tutorial - it's all text, but brief and to the point. You can see the source and demo. Definitely second the VS Express recommendation.

http://quickstarts.asp.net/QuickStartv20/aspnet/doc/masterpages/default.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜