Submit data to the SharePoint site in post mode in webpart

Source: Internet
Author: User

Because I usually work with usercontrol to develop complicated webparts, it refers to how to submit data to the SharePoint database in post mode by using usercontrol encapsulated in webpart.

By default, WSS sites do not support web applications.ProgramTo update database data through the POST method, you must add security verification information to the Web application. Such security verification information contains two different security layers: security Compliance is set for updating the security of a single site or site set, and for updating the virtual server or WSS of the website.
The first type of security verification is usually the security verification required when the application updates the business data on the site. The method to add this verification is as follows:

1. Add the following statement to the header of the ASPX page (note the following:CodeThe segment must be on the same line; otherwise, the compiler has an error.

): <% @ Register tagprefix = " SharePoint " Namespace = " Microsoft. Sharepoint. webcontrols " Assembly = " Microsoft. Sharepoint, version = 11.0.0.0, culture = neutral, publickeytoken = 71e9bce111e9429c "   %>

2. Add the formdigest verification control to the data to be submitted on the ASPX page. The added form is similar: < Form ID = " Form1 " Method = " Post " Runat = " Server " >
< SharePoint: formdigest runat = " Server " />
< ASP: button ID = " Button1 " Style = " Z-INDEX: 101; left: 282px; position: absolute; top: 282px " Runat = " Server " Text = " Button " > </ ASP: button >
</ Form >

After being added, the ASPX page sometimes appears and cannot be visually designed (for unknown reasons). You can design the page Department before joining formdigest.

3. When a client requests a webpage with a verification control, the server generates an HTML page for the request and adds security verification information to the page. When the client submits data, the server verifies security information, if no modification is made, no exception is triggered. Otherwise, the execution stops.

4. If the background code is to execute the SharePoint website management task, you need higher permissions by adding the following code to the codebehind file:

Spglobaladmin globaladmin =   New Spglobaladmin ();
Context. items [spglobaladmin. requestfromadminport] =   True ;
Page. registerhiddenfield ( " _ Requestdigest " , Globaladmin. adminformdigest );

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.