Solved

Disable and Input field in Sharepoint Developer

Posted on 2010-08-30
1
660 Views
Last Modified: 2012-05-10
In my editform.aspx I have several fields that I don't want the client to be able to edit but they should see them.  As an old ASP developer this could be done simply in code on the input field item by adding the keywords DISABLED or READONLY.

Is there a way to do this in sharepoint developer?
0
Comment
Question by:Matt Pinkston
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 8

Accepted Solution

by:
sandipkharde earned 500 total points
ID: 33560663
Here is an updated version of the code if you want to use it for multiple fields. You can simply call SetTextFieldReadOnly for each text field you want to hide.

1-  Edit the EditForm.aspx page
If the Edit Page option is missing from the Site Actions menu, use the ToolPaneView=2 URL parameter.
Ex: /EditForm.aspx?ToolPaneView=2
2- Add a Content Editor Web Part
3-  Add the following code

Go through ths -  
http://nishantrana.wordpress.com/2009/01/30/read-only-field-in-sharepoint-editformaspx/
<script type="text/javascript" src="[YOURPATHTOPROTOTYPE]/prototype.js"></script>
<script type="text/javascript">
function SetTextFieldReadOnly(name)
{
    var inputs = $$('input[title="' + name + '"]');
    if (null != inputs && inputs.length == 1) {
        var input = inputs[0];
        var label = "<span>" + input.getValue() + "</span>";
        Element.insert(input, {before: label});
        input.hide();
    }
}
function SetReadOnly()
{
    SetTextFieldReadOnly('Title');
    SetTextFieldReadOnly('Question');
}
_spBodyOnLoadFunctionNames.push("SetReadOnly");
</script>

Open in new window

0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you create your solutions on SharePoint sooner or later you will come upon a request to set  permissions of the item depending on some of the item's meta-data - the author, people assigned as approvers, divisions, categories etc. The most natu…
We had a requirement to extract data from a SharePoint 2010 Customer List into a CSV file and then place the CSV file into a directory on the network so that the file could be consumed by an AS400 system. I will share in Part 1 how to Extract the Da…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question