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

Disable Edit & HTML mode on checkbox click using javascript

3 Answers 106 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Ajay
Top achievements
Rank 2
Ajay asked on 03 Jul 2012, 01:45 PM
Dear Telerik Admin,
Can you please help me fnd solution to my problem.
I have a checkbox within my application & on client click of it I call an javascript function which display & hide panel control. Now I have also an RadEditor within my form, now what I want to do here is that, when I unchecks my check box  I want Content within the RadEditor to be in only PREVIEW MODE (i.e I wont allow user to view edit & HTML view modes), but when user check an checkbox control all I want to show is EDIT & HTML view modes & no preview mode.

Though I have tried to implement the same as shown below :-
function OnClientClick() {
               var IsCustomPageHeaderCheckBox = document.getElementById('<%= IsCustomPageHeaderCheckBox.ClientID %>');
               var TemplateHeaderPanel = document.getElementById('<%= TemplateHeaderPanel.ClientID %>');
               var editor = $find("<%=PageHeaderRadEditor.ClientID%>");
               var selectedvalue = IsCustomPageHeaderCheckBox.checked; // getting the selected value
               if (selectedvalue == true) {
                   TemplateHeaderPanel.style.display = 'none';
                   editor.set_mode(1); //Design mode
                   editor.set_mode(2); //Html mode
                    
               }
               else {
                   TemplateHeaderPanel.style.display = 'block';
                   editor.set_mode(4); //Preview mode
               }
 
           }
But its not working for me.

Also, I want the same feature on (!PageIsPostBack) on code behind.


Can you help me out ?

Thanks

Ajay

3 Answers, 1 is accepted

Sort by
0
Accepted
Rumen
Telerik team
answered on 03 Jul 2012, 03:35 PM
Hello,

You can use the EditModes enum server property of RadEditor to hide and show the Design, HTML and Preview modes of RadEditor on the server. Check this demo for more information: EditModes.

Kind 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.
0
Ajay
Top achievements
Rank 2
answered on 04 Jul 2012, 05:47 AM
Hi Rumen,

Thanks a lot for your reply.

It doesnt seemed to be working at my end, though I had given it a try.

I'm using it as :-

int MenuPageID = Convert.ToInt32(MenuPageIDHiddenField.Value);
        DataTable ADataTable = Glb_Entities.ExecuteSPReturnDT(new object[] {"Usp_Page_Content_Select"       
                                                                                ,"@Menu_Page_Id",MenuPageID      
                                                                               });
        if (ADataTable != null && ADataTable.Rows.Count > 0)
        {
 
            // Fill Page Content Details;
            IsCustomPageHeaderCheckBox.Checked = Convert.ToBoolean(ADataTable.Rows[0]["Page_Content_CustomPageHeaderStatus"].ToString());
            if (IsCustomPageHeaderCheckBox.Checked == true)
            {
                TemplateHeaderPanel.Style.Add("display", "none");
                PageHeaderRadEditor.EditModes = Telerik.Web.UI.EditModes.All;
 
 
            }
            else
            {
                TemplateHeaderPanel.Style.Add("display", "block");
                PageHeaderRadEditor.EditModes = Telerik.Web.UI.EditModes.Preview;
 
 
            }
 Any help ?

Ajay
0
Ajay
Top achievements
Rank 2
answered on 04 Jul 2012, 06:58 AM
Hey Rumen ,

Apologies here.... I found the problem on QUICK WATCH. I guess I was out of my senses but thankfully I resolved it ..

Anyways ..thanks for much help

Ajay :-)
Tags
Editor
Asked by
Ajay
Top achievements
Rank 2
Answers by
Rumen
Telerik team
Ajay
Top achievements
Rank 2
Share this question
or