Solved

Disable and Input field in Sharepoint Developer

Posted on 2010-08-30
1
648 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

For SharePoint sites, particularly public-facing ones, there are times when adding JavaScript, Meta Tags, CSS Styles or other content to the page <head> section is more practical than modifying master pages.  For instance, you could add the jQuery l…
The vision: A MegaMenu for a SharePoint portal home page The mission: Make it easy to maintain. Allow rich content and sub headers as well as standard links. Factor in frequent changes without involving developers or a lengthy Dev/Test/Prod rel…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

740 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