Stripping script tags

8 posts, 0 answers
  1. Matt
    Matt avatar
    6 posts
    Member since:
    Oct 2008

    Posted 28 Oct 2008 Link to this post

    Hi
    Is there a method for stripping out any 'script' tags after the submit button has been pressed?

    Thanks
    Matt
  2. Rumen
    Admin
    Rumen avatar
    14105 posts

    Posted 28 Oct 2008 Link to this post

    Hi Matt,

    The RemoveScripts client filter of RadEditor strips all script tags on submit or when switching to Html mode. It is enabled by default. If it is disabled on your side, you can enable it with

    C#:

    RadEditor1.EnableFilter(Telerik.Web.UI.EditorFilters.RemoveScripts);

    Best regards,
    Rumen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Matt
    Matt avatar
    6 posts
    Member since:
    Oct 2008

    Posted 28 Oct 2008 Link to this post

    Hi

    The filter works when switching between HTML mode and design mode, however, if you just create a script in HTML mode and click the submit button the 'script' tags don't seem to get removed.

    I have this in my code: -

    RadEditor1.EnableFilter(EditorFilters.RemoveScripts)

    Thanks
    Matt

  4. Rumen
    Admin
    Rumen avatar
    14105 posts

    Posted 28 Oct 2008 Link to this post

    Hi Matt,

    My suggestion is to programmatically switch to Design mode before submitting the content. Here is an example:

        <telerik:RadEditor ID="RadEditor1" runat="server">
            <asp:Button ID="Button1" runat="server" OnClientClick="SwitchEditor()" Text="Button" OnClick="Button1_Click" />
            <asp:TextBox ID="TextBox1" runat="server" Height="127px" TextMode="MultiLine"></asp:TextBox>
            <script type="text/javascript">
            function SwitchEditor()
            {
                var editor = $find("RadEditor1");
                editor.set_mode(1); //switch to Design mode
            }
            </script>

    Codebehind:

        protected void Button1_Click(object sender, EventArgs e)
        {
            TextBox1.Text = RadEditor1.Content;
        }

    Kind regards,
    Rumen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Matt
    Matt avatar
    6 posts
    Member since:
    Oct 2008

    Posted 28 Oct 2008 Link to this post

    Thanks Rumen, that works fine, is there a way of making the HTML view button not appear at all?
  6. Tervel
    Admin
    Tervel avatar
    1337 posts

    Posted 29 Oct 2008 Link to this post

    Hello Matt,

    Hiding the HTML mode is even easier and can be set with a property.
    The following online demo demonstrates that:
    http://demos.telerik.com/aspnet/prometheus/Editor/Examples/EditModes/DefaultCS.aspx

    The property is EditModes ="Design,Preview"

    Best wishes,
    Tervel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. Patrice Boissonneault
    Patrice Boissonneault avatar
    18 posts
    Member since:
    Mar 2010

    Posted 11 Apr 2011 Link to this post

    Is it possible to do the same with a textbox multiline?
  8. Rumen
    Admin
    Rumen avatar
    14105 posts

    Posted 14 Apr 2011 Link to this post

    Hi Patrice,

    Could you please explain what do you want to achieve? What do you mean by a multi-line textbox? Do you mean RadTextBox, a mult-iline Asp:TextBox or another control?

    Kind regards,
    Rumen
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top