Add properties or delete list folder content type

Source: Internet
Author: User
Private void button#click (Object sender, eventargs e) {string weburl = "http: // richsharepoint: 90/applicationmanagement"; spsecurity. runwithelevatedprivileges (delegate () {using (spsite site = new spsite (weburl) {using (spweb = site. openweb ("applicationmanagement") {splistcollection lists = web. lists; splist list = NULL; For (INT I = 0; I <lists. count; I ++) {list = lists [I]; If (isneedlist (list. title) {extendfolderperproty (Web, list) ;}}}});} private bool isneedlist (string listname) {string [] listnames = new string [] {"picturelibraryanson"}; For (INT I = 0; I <listnames. length; I ++) {If (listnames [I]. tostring () = listname) {return true ;}} return false;} private void extendfolderperproty (spweb, splist list) {spcontenttype Ct = List. contenttypes ["folder"]; Ct. sealed = false; // remove the properties CT. fieldlinks. delete ("numbercolumn"); Ct. fieldlinks. delete ("direct_x0020_link"); Ct. fieldlinks. delete ("media_x0020_category"); Ct. fieldlinks. delete ("market_x0020_category"); Ct. update (); // web. fields. add ("numbercolumn", spfieldtype. number, false); // spfieldlink flink1 = new spfieldlink (web. fields ["numbercolumn"]); // CT. fieldlinks. add (flink1); // Add direct link column string hcolumnname = "direct link"; web. fields. add (hcolumnname, spfieldtype. URL, false); spfieldlink HLINK = new spfieldlink (web. fields [hcolumnname]); Ct. fieldlinks. add (hlink); // Add media Category column mediachoicecolumn (Web, CT); Ct. update ();} private void mediachoicecolumn (spweb, spcontenttype CT) {string columnname = "media category"; web. fields. add (columnname, spfieldtype. choice, false); spfieldchoice choicefield = (spfieldchoice) web. fields [columnname]; // Add a group to the filed // choicefield. group = "mygroup"; // Add choices string [] choiceitems = new string [] {"Bulletin", "Junior poster", "poster", "spectacular ", "wall", "wrapped building/poster", "mobile billboard", "Airport Media", "Bus Media", "rail/subway Media", "Taxi Media ", "mall Media", "sports media (ARENA/Stadium)", "Street Furniture", "place-based media (not digital)", "alternative/promotional media ", "Guerilla Media", "street teams", "experiential/event", "digital billboard", "Digital spectacular", "Digital poster", "digital street furniture ", "Digital airport Media", "Digital transit Media", "digital mobile media", "Digital taxi Media", "digital projection Media", "Digital place based-Medical & Fitness ", "Digital place based-Education & office", "Digital place based-Leisure", "Digital place based-retail", "Digital alternative media", "mobile media "}; for (Int J = 0; j <choiceitems. length; j ++) {// Add choice choicefield. choices. add (choiceitems [J]. tostring ();} choicefield. editformat = spchoiceformattype. dropdown; // set the default choice choicefield. defaultvalue = "Bulletin"; choicefield. update (); spfieldlink FL = new spfieldlink (choicefield); Ct. fieldlinks. add (FL);} // Delete list folder content type private void button2_click (Object sender, eventargs e) {string weburl = "http: // shengvm77: 84 "; try {spsecurity. runwithelevatedprivileges (delegate () {using (spsite site = new spsite (weburl) {using (spweb = site. openweb ("homeanson") {splistcollection lists = web. lists; splist list = NULL; For (INT I = 0; I <lists. count; I ++) {list = lists [I]; If (list. title = "picanson") {spcontenttype Ct = List. contenttypes ["folder"]; List. contenttypes. delete (Ct. ID); list. update (); break ;}}}});} catch (exception ex) {MessageBox. show (ex. message );}}

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.