Search code examples
c#asp.netdotnetnukedotnetnuke-6

How to make DNN textfield readonly


How do you make a textfield readonly in DotNetNuke?

I have this code but its not working:

DnnFormTextBoxItem.Enabled = false;

Solution

  • In DotnetNuke, I only use dnn tag for text editor, with text field I use asp:TextBox tag and it can be disable or set readonly. But if you use dnn:Texteditor then there is no way to disable or set it to readonly. It only can be setted to visible or invisible.

    Another solution for disable a texteditor in DotnetNuke is to retrive value from texteditor and paste it to a label then hide the text editor.

    I have a short code here in C#. Imagine that you have a TextEditor1 and Label1 controls in your page and they are stay side-to-side to other but Label1 have an empty value. There is the code behind to setting an attribute for DNN TextEditor:

    string teValue = TextEditor1.Value;
    Label1.Text = teValue;
    TextEditor1.Visible = false;
    

    In the code above, you will show value of TextEditor1 in a Label (Label1) and then hide the TextEditor1 control, so that user only see the content of DNN TextEditor but nolonger be able to edit it after doing some post-back.