SharePoint : How to hide a field from the Edit Form?


I am not sure, how this can be achieved thro' UI. But here, Sharepoint Object model helps us.


localhost.Lists listService = new localhost.Lists();


            listService.Credentials= System.Net.CredentialCache.DefaultCredentials;


            XmlDocument xmlDoc = new System.Xml.XmlDocument();


            XmlNode ndUpdateFields = xmlDoc.CreateNode(XmlNodeType.Element, "Fields", "");


            ndUpdateFields.InnerXml = "<Method ID='1'>" +


                                                            "<Field ReadOnly='True' ShowInEditForm = 'FALSE' Type='Number' Name='_x0043_ol1' DisplayName='Col1'/>" +


                                                "</Method>";


            try


            {


                        XmlNode ndReturn = listService.UpdateList("Events", null, null, ndUpdateFields, null, null);


                        MessageBox.Show(ndReturn.OuterXml);


            }


            catch (Exception ex)


            {


                        MessageBox.Show("Message:\n" + ex.Message + "\nStackTrace:\n" + ex.StackTrace);


            }


 

Comments (1)
  1. Menerva says:

    Great job, it really help but the thing is how to implement it in sharepoint.

    what must i do to integrate the code in sharepoint.

    please i need that info, if any one know how please contact me at younes.menerva@gmail.com

Comments are closed.

Skip to main content