This is a migrated thread and some comments may be shown as answers.

Enabled = false Problem

5 Answers 344 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Bader
Top achievements
Rank 1
Bader asked on 02 Aug 2011, 10:49 AM
Hello,

I'm using the following RadEditor within the usercontrol of the Insert/Update/Delete RadGrid:
<telerik:RadEditor runat="server" ID="CntntRadEditor" Enabled="false" Height="500px" Width="100%" style="z-index:1000;" Content='<%# DataBinder.Eval( Container, "DataItem.Cntnt") %>' ToolsFile="~/Common/Controls/RadEditor/xml/CustomFullSetOfToolsForSecureTables.xml">
                            <Modules>
                                <telerik:EditorModule Visible="false" />
                            </Modules>
                            <ImageManager ViewPaths="~/Guide/Design/Contents" UploadPaths="~/Guide/Design/Contents" DeletePaths="~/Guide/Design/Contents" />
                            <DocumentManager ViewPaths="~/Guide/Design/Contents" UploadPaths="~/Guide/Design/Contents" DeletePaths="~/Guide/Design/Contents" SearchPatterns="*.doc,*.txt,*.docx,*.xls,*.xlsx,*.pdf,*.xml" />
                        </telerik:RadEditor>

The problem is that the RadEditor control is hidden by seeting the property Enabled=false.
If I remove that property, the RadEditor is displayed normally.
The requirements is to disable the RadEditor control in order to prevent the user from typing a text and from clicking any icon from the RadEditor toolbar.

Please, I need your help,
It is appreciated to send me the modified code.

Regards,
Bader

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 02 Aug 2011, 11:35 AM
Hello Bader,

You can try the following javascript to enable and disable RadEditor using a ButtonClick.
JS:
<script type="text/javascript">
var toggle = true;
function toggleEditing()
{
    var editor = $find("<%=RadEditor1.ClientID%>");
    toggle = !toggle;
    editor.enableEditing(toggle);
    editor.set_editable(toggle);
    if (toggle == false) editor.get_document().body.style.backgroundColor = "gray";
    else editor.get_document().body.style.backgroundColor = "";
}
</script>
aspx:
<telerik:RadEditor ID="RadEditor1" runat="server">
 . . . .
</telerik:RadEditor>
 <input type="button" onclick="toggleEditing();return false;" value="Toggle editing" />

Thanks,
Shinu.
0
Bader
Top achievements
Rank 1
answered on 03 Aug 2011, 07:36 AM
Hello,

Thank you for your reply,
Your solution doesn't meet the requirements.
Please look at the demo http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/usercontroleditform/defaultcs.aspx (Both RadEditor and The following RadComboBox are placed within the usercontrol).

I need to enable and disable the RadEditor control based on the selected value of a RadComboBox:
<telerik:RadComboBox ID="TypeRadComboBox" SelectedValue='<%# DataBinder.Eval( Container, "DataItem.Type" ).ToString().Trim() %>' runat="server" AutoPostBack="true" OnSelectedIndexChanged="TypeRadComboBox_SelectedIndexChanged" Width="215px">
                        <Items>
                            <telerik:RadComboBoxItem runat="server" Text="Folder" Value="Folder" />
                            <telerik:RadComboBoxItem runat="server" Text="Document" Value="Document" />
                        </Items>
                        <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
                    </telerik:RadComboBox>
protected void TypeRadComboBox_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
{
RadComboBox combo = (RadComboBox)o;
if(combo.SelectedValue.Equals("Folder"))
CntntRadEditor.Enabled = false;
else CntntRadEditor.Enabled = true;
}

The problrm is when I select the "Floder" value, then the radEditor get hidden

Please, I need you help,
It is appreciated to send me the modified code.

Regards,
Bader
0
Steve
Top achievements
Rank 1
answered on 29 Aug 2011, 10:37 AM
Instead of disabling the editor, you can achieve the functionality you desire (visible, but non-functioning editor tool bars and "locked" text) by setting the editor's editmode to 'preview' mode, and then toggling the editmode back to 'design' mode to "re-enable" the editor.

e.g.
protected void TypeRadComboBox_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
{
RadComboBox combo = (RadComboBox)o;
if(combo.SelectedValue.Equals("Folder"))
CntntRadEditor.EditMode = EditMode.Preview;
else CntntRadEditor.EditMode = EditMode.Design;
}

I hope this helps.
0
KOGAN
Top achievements
Rank 1
answered on 21 Oct 2012, 08:10 AM
Hi,

I'm facing a similar issue when the RadEditor is placed within a Panel Control.
By disabling (Enable=false) the Panel control, all controls that are inside it, are disabled too except to the RadEditor control.
what I should do in this situation?

Regards,
Bader
0
Rumen
Telerik team
answered on 24 Oct 2012, 01:09 PM
Hi,

You can put RadEditor in Preview mode as suggested before. The Enabled property of RadEditor set to false, renders a DIV element with the RadEditor's content in it. The RadEditor1.EditModes = EditMode.Design; renders the RadEditor in Preview mode and the editor is disabled.

Regards,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Editor
Asked by
Bader
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Bader
Top achievements
Rank 1
Steve
Top achievements
Rank 1
KOGAN
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or