Custom SharePoint forms-(1)

Source: Internet
Author: User

A major problem encountered when developing Sharepoint is that all list items are displayed in the same way. This is not applicable when forms are complex or form actions are required. The most convenient way to think of in SharePoint 2007 is to use infopath integration. Infopath can create forms in various forms. These forms can be directly displayed on web pages through form service, and can interact directly with workflow to solve most of the problems we can encounter. It's a pity that microsfot will not be delivered to you. Both moss2007 and office2007 require a lot of money. No way. You can solve this problem by yourself.

The SharePoint display page is controlled by webpart. The webpart generates HTML based on all related templates. SharePoint stores all templates under the SharePoint installation directory Program Files \ common files \ microsoft shared \ Web Server Extensions \ 12 \ template \ controltemplates. The file defaulttemplates. ascx contains the templates that will be used under different scenario. For example, the template whose lid is listform. The View/Edit list item Page is controlled by it.

 


< SharePoint: renderingtemplate ID = "Listform" Runat = "Server" >
< Template >
< Span ID = 'Part1' >

<SharePoint: informationbarRunat= "Server"/>

-- I think it should be the page title that displays the brief information of the current item

< Wssuc: Toolbar Cssclass = "MS-formtoolbar" ID = "Toolbartbltop" Rightbuttonseparator = "& Nbsp ;" Runat = "Server" >
< Template_rightbuttons >
< SharePoint: nextpagebutton Runat = "Server" />
< SharePoint: savebutton Runat = "Server" />
< SharePoint: gobackbutton Runat = "Server" />
</ Template_rightbuttons >

</Wssuc: Toolbar>

-- OK button, close button, and cancel button are displayed according to different situations.

 
<SharePoint: formtoolbarRunat= "Server"/>
-- Form toolbar: new item, edit item, delete item, etc.

< Table Class = "MS-formtable" Style = "Margin-top: 8px ;" Border = 0 Cellpadding = 0 Cellspacing = 0 Width = 100%>
<SharePoint: changecontenttype runat = "Server" />
< SharePoint: folderformfields Runat = "Server" />
< SharePoint: listfielditerator Runat = "Server" /> (Controls that display all View fields)
< SharePoint: approvalstatus Runat = "Server" />
< SharePoint: formcomponent Templatename = "Attachmentrows" Runat = "Server" />

</Table>

-- This part shows the content of the list item.

< Table Cellpadding = 0 Cellspacing = 0 Width = 100%> <tr> <TD Class = "MS-formline" > < IMG SRC = "/_ Layouts/images/blank.gif" Width = 1 Height = 1 ALT = "" > </ TD > </ Tr > </ Table >
< Table Cellpadding = 0 Cellspacing = 0 Width = 100% Style = "Padding-top: 7px" > < Tr > < TD Width = 100%>
<SharePoint: itemhiddenversion runat = "Server" />
< SharePoint: parentinformationfield Runat = "Server" />
< SharePoint: initcontenttype Runat = "Server" />
< Wssuc: Toolbar Cssclass = "MS-formtoolbar" ID = "Toolbartbl" Rightbuttonseparator = "& Nbsp ;" Runat = "Server" >
< Template_buttons >
< SharePoint: createdmodifiedinfo Runat = "Server" />
</ Template_buttons >
< Template_rightbuttons >
< SharePoint: savebutton Runat = "Server" />
< SharePoint: gobackbutton Runat = "Server" />
</ Template_rightbuttons >

</Wssuc: Toolbar>

-- form bottom button: OK, close, cancel, save ..
TD > tr > table >
span >

<SharePoint: attachmentuploadRunat= "Server"/>

-- Upload the attachement Control
</Template>

</SharePoint: renderingtemplate

 

Theoretically, you only need to modify the corresponding template to change the layout of the page display. However, the defaulttemplates file is a system file that is overwritten during WSS updates. It is also dangerous to directly modify the system file. Fortunately, WSS supports renderingtemplate customization. You only need to create an ascx file under controltemplates and add a template to it. The newly added template will overwrite the template defined by the same ID in the default template. For example:

1. Create a New customlistform. ascx file and store it in the controltemplates directory.

2. Add various file headers

< % @ Control Language = "C #" Autoeventwireup = "False" % >
< % @ Assembly Name = "Microsoft. Sharepoint, version = 12.0.0.0, culture = neutral, publickeytoken = 71e9bce111e9429c" % >
< % @ Register Tagprefix = "SharePoint" Assembly = "Microsoft. Sharepoint, version = 12.0.0.0, culture = neutral, publickeytoken = 71e9bce111e9429c" Namespace = "Microsoft. Sharepoint. webcontrols" % >
< % @ Register Tagprefix = "Sphttputility" Assembly = "Microsoft. Sharepoint, version = 12.0.0.0, culture = neutral, publickeytoken = 71e9bce111e9429c" Namespace = "Microsoft. Sharepoint. Utilities" % >
< % @ Register Tagprefix = "Wssuc" Tagname = "Toolbar" SRC = "~ /_ Controltemplates/toolbar. ascx" % >
< % @ Register Tagprefix = "Wssuc" Tagname = "Toolbarbutton" SRC = "~ /_ Controltemplates/toolbarbutton. ascx" % >

 

3. Copy the part with the ID of listform in defatemtemplates to the next one. Save the file.

4. Then you can modify the file as needed, save the modification, and restart IIS to see the effect.

Have you seen it! The button under form is deleted. Although this design is not bad, It is wronged to show the effect.

 

Although this method can solve some problems, there are more problems:

1. This is a global change, which affects all relevant places and cannot be used separately for a list or a scenario.

2. layout can be modified using this method. But how do I operate field-level data? The field is generated by using the listfielditerator control. The layout of the field content cannot be controlled by modifying the template.

So... let's have a break. I need to research more to get answers ....

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.