The use of master pages can maintain the same style of the site, and the use of Sharepoint is as simple as that of ASP. NET websites.
1. Use the master page that comes with WSS.
The WSS master page is located at: C: \ Program Files \ common files \ microsoft shared \ Web Server Extensions \ 12 \ template \ global
As you can see, there are many placeholders. we can add the placeholder content to the subpage.
Continue to use the example in the previous section.
Change the content of the aspx file: <% @ Page Language = " C # " Masterpagefile = " ~ Masterurl/Default. Master " %>
< ASP: Content Contentplaceholderid = "Placeholdermain" Runat = "Server" >
< ASP: textbox ID = "Txt1" Runat = "Server" Width = "100" > </ ASP: textbox >
< ASP: button ID = "Btn1" Runat = "Server" Text = "Button" Onclick = "Showmessage" />
</ ASP: Content >
script type =" text/C # " runat =" server " >
void showmessage (Object sender, eventargs e)
{< br> txt1.text = " my page !! " ;
}< br> script >
Then deploy the settings and run the result.
Note:
Masterpagefile = "~ ~ In masterurl/Default. Master ~ Masterurl is the path constant of the SharePoint master page.
Vs2008 + svcs1.2 cannot automatically find the master page under this path. Therefore, an error occurs when switching to the design view. The solution is to design the directory of the newly created module copied such as the master page.
Add the contentplaceholder corresponding to the master page to set the content of the placeholder.
2. custom mother page
in addition to the system master page, you can customize the mother page.
the method is also very simple.
Create a new name named mymaster. master file with the same content structure as ASP.. Net master page: <% @ master language = " C # " %>
<!Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< Html Xmlns = "Http://www.w3.org/1999/xhtml" >
< Head Runat = "Server" >
< Title > Master page-floating remote blog http://www.xianfen.net/ </ Title >
</ Head >
< Body Style = "Background-color: # 83b0ec ;" >
< Form ID = "Form1" Runat = "Server" >
< Div Style = "Margin-top: 50px; margin-left: 50px; Background-color: # ffe59d; width: 500px; Height: 100px ;" >
< ASP: contentplaceholder ID = "Contentplaceholder1" Runat = "Server" >
</ ASP: contentplaceholder >
</ Div >
</ Form >
</ Body >
</ Html >
The sub-page content is: <% @ Page Language = " C # " Masterpagefile = " Mymaster. Master " Title = " Child pages-floating remote blog http://www.xianfen.net/ " %>
< ASP: Content Contentplaceholderid = "Contentplaceholder1" Runat = "Server" >
< ASP: textbox ID = "Txt1" Runat = "Server" Width = "100" > </ ASP: textbox >
< ASP: button ID = "Btn1" Runat = "Server" Text = "Button" Onclick = "Showmessage" />
</ ASP: Content >
script type =" text/C # " runat =" server " >
void showmessage (Object sender, eventargs e)
{< br> txt1.text = " my page !! " ;
}< br> script >
After compilation and deployment settings, the running effect
Download example: Click to download
Floating remote blog: http://www.cnblogs.com/zxjay/
Author: piaoyao (Zhou Zhenxing)