Disable Edit & HTML mode on checkbox click using javascript

4 posts, 1 answers
  1. Ajay
    Ajay avatar
    66 posts
    Member since:
    May 2009

    Posted 03 Jul 2012 Link to this post

    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

  2. Answer
    Rumen
    Admin
    Rumen avatar
    12851 posts

    Posted 03 Jul 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ajay
    Ajay avatar
    66 posts
    Member since:
    May 2009

    Posted 04 Jul 2012 Link to this post

    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
  5. Ajay
    Ajay avatar
    66 posts
    Member since:
    May 2009

    Posted 04 Jul 2012 Link to this post

    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 :-)
Back to Top