More in this section

Forums / Developing with Sitefinity / Problems when adding javascript from server side within a module

Problems when adding javascript from server side within a module

3 posts, 0 answered
  1. Olivier
    Olivier avatar
    11 posts
    Registered:
    13 May 2008
    18 Jun 2008
    Link to this post
    Hi,

    I'm developping a module,

    I've added some javascript to the page using : Page.ClientScript.RegisterClientScriptBlock inside my editor which type is CompositeControl
    I've also added two Button controls to handle a javascript event to add and remove items from a listbox but on client side.

    The problems i have : i get a javascript error when clicking my button ; my buttom is postbacking even if i put the causevalidation attribute to false; the other thing is that it's breaking also the other button fonctionalities (like back, cancel..)

    Is there something special to do when adding some javascript code from the server side?

    Thanks
  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    18 Jun 2008
    Link to this post
    Hi Olivier,

    You should not have any problems when you add javascript from the server side. Here is a simple example:

    private void Redirect(string url) 
            { 
                string script = "parent.location='" + url + "';"
                this.Page.ClientScript.RegisterClientScriptBlock(GetType(), "redirect", script, true); 
            } 
     
    Most probably, the reason for the errors is in the javascript code itself. What kind of errors do you receive? It will be very helpful if you send us your custom control to test it locally.

    Thanks for your cooperation in advance.

    All the best,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Olivier
    Olivier avatar
    11 posts
    Registered:
    13 May 2008
    19 Jun 2008
    Link to this post
    Hi, Thanks for the reply, you were right , i had something wrong in my javascript....
Register for webinar
3 posts, 0 answered