Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm developing a user control containing textfields bound to my list SPListFields and I'm using this user control twice with two different modes ( Edit or New).

In my Edit mode I want to disable a TextField wich is bound to the SPListItem Code but I didn't now how to do it from code behind ??

Here's the TextField Code :

TextField MyCode = new TextField();
MyCode.ID = "MyCodeID";
MyCode.FieldName = "Code";
MyCode.ItemId = myItemID;
MyCode.ListId = myListID;
MyCode.ControlMode = Mode == OperationMode.Edit ? SPControlMode.Edit : SPControlMode.New;
Page.Controls.Add(MyCode);
if (Mode == OperationMode.Edit)
{
    MyCode.enabledViewState = false // this doesn't enable my textField
}
share|improve this question

2 Answers 2

up vote 2 down vote accepted

If you want the field to appear as read-only or display than you can change its SPControlMode to Display

MyCode.ControlMode = SPControlMode.Display

share|improve this answer

enabledViewState wouldn't enable/disable your field, try .Enabled instead.

share|improve this answer
    
that option doesn't exist –  Glolita Mar 25 '13 at 10:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.