Sample Code of helloword on the moss application page

Source: Internet
Author: User
The following is the sample code of the simplest application page. You only need to copy the page to the _ layouts directory.

<% @ Assembly name = "Microsoft. Sharepoint, [full 4-part assembly name]" %>
<% @ Page Language = "C #" masterpagefile = "~ /_ Layouts/application. Master"
Inherits = "Microsoft. Sharepoint. webcontrols. layoutspagebase" %>

<% @ Import namespace = "Microsoft. SharePoint" %>

<SCRIPT runat = "server">
Protected override void onload (eventargs e ){
Spsite sitecollection = spcontext. Current. Site;
Spweb site = spcontext. Current. Web;
Lblsitetitle. Text = site. title;
Lblsiteid. Text = site. Id. tostring (). toupper ();
}
</SCRIPT>

<Asp: Content ID = "Main" runat = "server"
Contentplaceholderid = "placeholdermain">
Site title: <asp: Label id = "lblsitetitle" runat = "server"/>
<Br/>
Site ID: <asp: Label id = "lblsiteid" runat = "server"/>
</ASP: content>

<Asp: Content ID = "pagetitle" runat = "server"
Contentplaceholderid = "placeholderpagetitle">
Hello World
</ASP: content>

<Asp: Content ID = "pagetitleintitlearea" runat = "server"
Contentplaceholderid = "placeholderpagetitleintitlearea">
Hello World
</ASP: content>

This code writes the onload code in the background on the ASPX page, but I prefer code-behind.
For example, if you want to create a customlogin project, there is only one login. ASPX page, put it in the _ layouts directory, you only need to put customlogin. put the DLL in the/layouts/bin directory.
But there is a problem. The _ layouts directory is already named as login. ASPX page. If our page is also placed in the _ layouts directory, it will overwrite the original login. aspx file. Therefore, we can create a subdirectory for our project under the _ layouts directory to store our custom files.
If you want to put the login. ASPX page in a sub-directory under the _ layouts directory, you must create the sub-directory as a virtual directory to use code-behind. That is, after creating the sub-directory customlogin, our login. the storage path of aspx is _ layouts \ customlogin \ login. aspx; while the backend customlogin. the DLL storage path is _ layouts \ customlogin \ bin \ customlogin. DLL.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.