How to add the main page to an already created web form?

I have an asp.net web application. Now I have to add the main page in this application, but I don’t know how to combine or add a new created main page with old web forms? How to handle html in web forms like <head> , <body> ? Any link in this regard would be helpful.

+4
source share
2 answers

1- Define fixed elements in your design and place them on the newly created home page

2- Define dynamic ones and add asp:ContentPlaceHolder for them (most often for HEAD , one for main content in your BODY and one for side content "if applicable")

 <asp:ContentPlaceHolder ID="CphHead" runat="server"> </asp:ContentPlaceHolder> 

3- On your pages add MasterPageFile="~/MASTER_PAGE_PATH" to the page directive.

4- Add asp:Content sections within your pages that will contain dynamic content on your pages, and remember to specify the correct ContentPlaceholder ID .

  <asp:Content ID="HeadContent" ContentPlaceHolderID="CphHead" runat="server"> // Your content goes here... </asp:Content> 

5- Copy the contents of your page inside these asp:Content and BOOOOM .... sections. You are done.

+6
source

at the top of the new page in the tag "<% @page @>" add "MasterPageFile =" ~ / Site.Master "'then add the required placeholders.

 <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> </asp:Content> 

of course change them to the names you use

+5
source

Source: https://habr.com/ru/post/1346700/


All Articles