.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

SharePoint: Multiple lines of text Field and Single line text as disabled or read-only

Posted By:Sagar Pardeshi       Posted Date: December 26, 2013    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

SharePoint: Multiple lines of text Field and Single line text as disabled or read-only
 

Introduction

Disabled or read-only to Multiple lines of text Field and Single line text  in Edit form in SharePoint list. 

Objective

 use of SharePoint Designer to make a field read only .Here is a method to make a field readonly using Jquey  and a Content Editor Web Part

Edit the EditForm.aspx page
If the Edit Page option is missing from the Site Actions menu, use the ToolPaneView=2 URL parameter.
Ex:

1.       /EditForm.aspx?ToolPaneView=2

2.       Add a Content Editor Web Part

3.       Add the following code (in this example, "Question" is the name of my field):

 

 

Using the code

 

<script language="javascript" src="/JSLibrary/jquery-1.9.0.min.js" type="text/javascript"></script><script language="javascript" type="text/javascript">


$(document).ready(function () {
       
            ConvertTextboxToLable('Title');
            ConvertTextareaToLable('Description');
});

    //Convert TextArea to Lable
    function ConvertTextareaToLable(colName) {
        var txtHTML = $("textarea[Title='" + colName + "']").html();
        var tdColumn = $("textarea[Title='" + colName + "']").closest('td');
        var tdColumnHTML = $(tdColumn).html();

        $(tdColumn).html("<div style='display:none'>'" + tdColumnHTML + "'</div>");
        $(tdColumn).append(txtHTML);
    }

    //Convert Textbox to Lable
    function ConvertTextboxToLable(colName) {
        var txtHTML = $("input[type=text][Title='" + colName + "']").val 
();
        var tdColumn = $("input[type=text][Title='" + colName +  
"']").closest('td');
        var tdColumnHTML = $(tdColumn).html();

        $(tdColumn).html("<div style='display:none'>'" + tdColumnHTML +  
"'</div>");
        $(tdColumn).append(txtHTML);
    }
</script>

 

Summary

In this article we have several requests for a solution for setting fields as read only in Edit Form.


 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend