+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Java script in Generic Content Control

Java script in Generic Content Control

7 posts, 0 answered
  1. Rama Krishna Reddy
    Rama Krishna Reddy avatar
    4 posts
    Registered:
    03 Aug 2011
    03 Aug 2011
    Link to this post

    Hi,

     

    We are using Sitefinity 3.5.1714

     

    We have a requirement to use JavaScript within a Generic Content control.  I  tried to add java script.  But the  scripts tags  <script type="text/javascript"> </script> gets erased when I click on I’m Done button.   The page is rendering the script as junk content instead of executing it.

     

    Please guide us to resolve this issue.

     

    Following is the sample content I’m trying to put it on Generic Content control.

     

    <html>
    <head>
    <script type="text/javascript">
    function displaymessage()
    {
    alert("Hello World!");
    }
    </script>
    </head>
      
    <body>
    <form>
    <input type="button" value="Click me!" onclick="displaymessage()" />
    </form>
      
    <p>By pressing the button above, a function will be called. The function will alert a message.</p>
      
    </body>
    </html>

     

    Thanks,

          RK

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    03 Aug 2011
    Link to this post
    Hello,

    Under Sitefinity/Admin/ControlTemplates/GenericContent/ there is a file EditorTemplate.ascx which contains the RadEditor control declaration. By default the control strips the scrip tags. You need to set AllowScripts property to true to fix the issue.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Rama Krishna Reddy
    Rama Krishna Reddy avatar
    4 posts
    Registered:
    03 Aug 2011
    03 Aug 2011
    Link to this post
    Hi Dimitrov,

    Thanks for the reply.  I already made that change in EditorTemplate.ascx file based on the information avialable in Sitefinity forums.  It's not resolving the issue.  Is it required any other modifications?     I am using IE 8.0.

    The content is changing as shown, after I click on I'm Done button.

    <html>
        <head>
            <title></title>
        </head>
        <body>
            function displaymessage() { alert("Hello World!"); }
            <form>
                <input onclick="displaymessage()" type="button" value="Click me!" />
            </form>
            <p>By pressing the button above, a function will be called. The function will alert a message.</p>
        </body>
    </html>


    Thanks,
         RK
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    03 Aug 2011
    Link to this post
    Hi,

    GenericContent uses RadEditor. Your scripts are stripped by the RadEditor. Please make sure that the filter is set to true and the HTML is valid. These are the cases when the <script> tags are removed.


    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Rama Krishna Reddy
    Rama Krishna Reddy avatar
    4 posts
    Registered:
    03 Aug 2011
    03 Aug 2011
    Link to this post
    Hi,
     
    This is the change I made in the EditorTemplae.ascx.

     

     

     

     

    <telerik:RadEditor  runat="server"  ID="RadEditor1" OnClientLoad="RadEditorLoad"
    ContentAreaCssFile="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorContentArea.css"
    ToolsFile="~/Sitefinity/Admin/ControlTemplates/EditorToolsFile.xml"
    EnableEmbeddedSkins="False"  Skin="Sitefinity" 
    DialogsCssFile="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorDialogs.css"
    NewLineBr="False" Height="360px"  Width="98%"
    AllowScripts="true"> 
      
    <ImageManager ViewPaths="~/Images" UploadPaths="~/Images" DeletePaths="~/Images" />
    <MediaManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
    <FlashManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
    <DocumentManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
    <CssFiles>
    <telerik:EditorCssFile Value="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorCssFile.css" />
    </CssFiles>
    </telerik:RadEditor>

    And I have added following simple java script in the Generic Content control.

     

    <body
    <input type="button" value="Click me!" onclick="displaymessage()" /> 
    </body
      
    <script type="text/javascript"
    function displaymessage() 
      alert("Hello World!"); 
    </script

    It seems, I followed everything guided by you. Still it's not working..

    Thanks,
        RK 

  6. Rama Krishna Reddy
    Rama Krishna Reddy avatar
    4 posts
    Registered:
    03 Aug 2011
    04 Aug 2011
    Link to this post

    Hi,
    AS per the Nikolay’s (Telerik team member ) comments on one of the Forums question,  I came to know that Sitefinity 3.5 has issues with Script tag  i.e.  Script tag  stripped from Generic Content Control and you provided fix with Sitefinity 3.5 Service Pack1. 
    Reference links:

    http://www.sitefinity.com/devnet/forums/sitefinity-3-x/bugs-issues/3-5-javascript-stripped-from-generic-content.aspx

    http://www.sitefinity.com/devnet/forums/sitefinity-3-x/general-discussions/sitefinity-3-5-sp1-available-for-download.aspx

    I couldn’t able to find the location to download Sitefinity 3.5 SP1.   Can you provide the url to download the same? 
    Currently we are using Sitefinity 3.5.1714 version.


    Thanks,
          RK

  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    04 Aug 2011
    Link to this post
    Hello Rama,

    Under the account which you used to download 3.5 edition you should be able to see all other versions as well.
    Your account is not associated with a download, so please use the account used for initial download.

    It would be better to upgrade to Sitefinity 3.7 SP4, because the version you use is about 3 years old and actually discontinued.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
7 posts, 0 answered