locked
Read Only column(s) on the EditForm.aspx RRS feed

  • Question

  • Stunpals asked the question "How do you have fields show up as "read-only" in the EditForm.aspx for a list? in 12/2010.  DavidLewis27 proposed the solution that Stunpals used of adding the following code:

    <SharePoint:FormField runat="server" id="ff1{$Pos}" ControlMode="Edit" FieldName="Title">
    
    

    This worked for Stunpals but I am unclear where to add this line of code to the file.  Also, for mulitple fields, is this line repeated, or can it be modified to inlcude multiple Fieldnames using pipes or ?

    I use SPD for workflows, etc but I have very limited coding experience.

    Thank you in advance.


    • Edited by Mike Walsh FIN Saturday, April 23, 2011 6:02 AM - revisit removed from Title.
    • Moved by Mike Walsh FIN Friday, July 29, 2011 5:53 PM spd q (From:SharePoint - General Question and Answers and Discussion (pre-SharePoint 2010))
    Friday, April 22, 2011 11:02 PM

Answers

  • Hi Alex,

    If you are unable to find the code that you seek, you may not be looking at a customized editform.aspx page. 

    In order to find the field you need, using SharePoint designer 2007 you can:

    1. Create a copy of your original EditForm.aspx
    2. Open the Copy of your original and right click on the default ListFormWebPart and select web part properties.
    3. Expand + Layout and make sure the 'Hidden' check box is checked.
    4. Add a Custom list form by clicking 'Insert > SharePoint Controls > Custom List Form'
    5. Select the appropriate Document Library, Content type and type of form (in your case Edit item form) and click OK
    6. Make sure you are in 'SPLIT' view and then in the design window, click on the text box that you want to be read only.  The corresponding code will be highlighted in the code window.  Find the portion of the code that says ControlMode="Edit" and change it to ControlMode="Display"

    This will convert the field to Read Only for this form.

     


    - Xenox G.
    • Marked as answer by Alex Draffan Thursday, April 28, 2011 10:27 PM
    Thursday, April 28, 2011 7:46 PM

All replies

  • Hello,

    In designer, if you navigate into your list on the left side you will find all the forms, open the EditForm.aspx and make sure you edit it in "Advanced Mode" which can be found on the top right corner of the designer menu ribbon. Search for the required field and you will find it.

    Hope the information helps, please do let us know the outcome


    Thanks & Regards, Chandra Shekhar Rameneni
    Saturday, April 23, 2011 11:46 AM
  • Chandra - Thank you for your response.  I am working in SPD 2007, so I don't have an option for editing in advanced mode.  However, from a brief search on the web, I think when I choose to opent the EditForm.aspx with an editor (I use Crimson Editor) that should work the same.

    When viewing the .aspx file with the editor, I do not see any of the column names listed individually.  Am I missing something?

    R/

    Alex

    Monday, April 25, 2011 8:23 PM
  • No you're not missing anything. The page will typically open the page layout and not the content.  I don't think you'll need it though.  I've only had a quick look at the thread but looking at the code you've posted, just edit the segment of the code below to include the static name of the column you want to change to read only.  I've quoted some text below from Marc Anderson that explains how to locate the static name of your column.

    "StaticName (as opposed to DisplayName) means the underlying column name, e.g., Region_x0020_Name. This is also sometimes called the 'internal name' for the column. The DisplayName would be Region Name, i.e., the name of the column which is shown on forms and as the header in list views. Probably the easiest way to determine the StaticName if you don't know it is to go to List Settings and click on the column name link. When you get to the column properties page, check the URL. It will end in something like this:
    /_layouts/FldEdit.aspx?List=%7B37920121%2D19B2%2D4C77%2D92FF%2D8B3E07853114%7D&Field=Potential%5Fx0020%5FValue
    The StaticName is the value for the Field parameter at the end. This is a little tricky because some of the characters are further encoded. Any occurrences of '%5F' need to be replaced with an underscore '_'. Examples:

        * Potential%5Fx0020%5FValue -> Potential_x0020_Value
        * Child%5Fx0020%5FSite%5Fx0020%5FName -> Child_x0020_Site_x0020_Name"

     FieldName="StaticName">

    Steven Andrews | SharePoint Professional | http://www.twitter.com/backpackerd00d | https://baron72.wordpress.com/
    Tuesday, April 26, 2011 12:27 PM
    Answerer
  • All,

    I am still not finding it.  My goal is to have all fields editable, but the 2nd field "Purpose" as read-only.  From looking at the EditForm.aspx, it looks like the file has a template for how the fields are displayed that is repeated for each of the columns in the list, but I can't figure out where to insert the code.  Please take a look at my file and see if you can tell me where the code fits in.

     https://docs.google.com/leaf?id=0B-bAzy74L-TRYjA3MTZjMzUtMjkyYS00NTBkLTkyMGEtYTA1YjI0ZDIwODU1&sort=name&layout=list&num=50

    The file consists of 1) content editor web part with some text, 2)the list display web part where I am trying to modify how the columns are displayed, and 3) a second content editor web part with some java script to hide some of the columns.  (Note: Could I accomplish the same thing (make column display only) by adding to the java script in the second content editor web part?)

    Your assitance is appreciated.

    R/

    Alex

    Wednesday, April 27, 2011 6:11 PM
  • Do you know how to make a list template?  I'd like to work with what you have to see if I can make this work.  Can you generate an stp and send it to me at baron_72@hotmail.com and I'll take a look for you, with a view of posting a solution here for the community.
    Steven Andrews | SharePoint Professional | http://www.twitter.com/backpackerd00d | https://baron72.wordpress.com/
    Thursday, April 28, 2011 2:24 PM
    Answerer
  • Hi Alex,

    If you are unable to find the code that you seek, you may not be looking at a customized editform.aspx page. 

    In order to find the field you need, using SharePoint designer 2007 you can:

    1. Create a copy of your original EditForm.aspx
    2. Open the Copy of your original and right click on the default ListFormWebPart and select web part properties.
    3. Expand + Layout and make sure the 'Hidden' check box is checked.
    4. Add a Custom list form by clicking 'Insert > SharePoint Controls > Custom List Form'
    5. Select the appropriate Document Library, Content type and type of form (in your case Edit item form) and click OK
    6. Make sure you are in 'SPLIT' view and then in the design window, click on the text box that you want to be read only.  The corresponding code will be highlighted in the code window.  Find the portion of the code that says ControlMode="Edit" and change it to ControlMode="Display"

    This will convert the field to Read Only for this form.

     


    - Xenox G.
    • Marked as answer by Alex Draffan Thursday, April 28, 2011 10:27 PM
    Thursday, April 28, 2011 7:46 PM
  • Thank you Xenox.  This worked best for me.  I was able to select the field in the custom list webpart and change the display in the "Tag Properties" window on the left side. The less actual coding the better for me, but now that the .aspx is in this format the orginal code-based solution would work as well.  Maybe I missed that step on the previous string I quoted.

    R/

    Alex


    • Edited by Mike Walsh FIN Friday, April 29, 2011 6:58 AM Ask new questions in a new thread. This one is closed.
    Thursday, April 28, 2011 10:36 PM