how to differentiate javascript in 2 radwindow in a page

2 posts, 0 answers
  1. ekc ekc
    ekc ekc avatar
    17 posts
    Member since:
    Mar 2010

    Posted 02 Nov 2010 Link to this post


    I've this javascript:

    function radwin_close(radWin) {

    var objArg;
    objArg = radWin.Argument;
    document.getElementById("<%= txtPath.ClientID %>").value = objArg.Path

    I'm calling this function on RadWindowManager: OnClientClose="radwin_close". I'm putting this as a user control, if I have 2 same user controls (1.ascx, 2.ascx) in the same page, in runtime, the page will generate 2 same function radwin_close(radWin). so how can i differentiate when i open radwindow from 1.ascx, it will call the 1.ascx javascript function?

  2. Georgi Tunev
    Georgi Tunev avatar
    7207 posts

    Posted 03 Nov 2010 Link to this post

    Hi ekc,

    In such scenario, only the radwin_close() function that is rendered last on the page will be executed - as it will override the one rendered previously.
    What I would suggest is to give a different name to the JS function depending on (for example) RadWindow's ClientID property.
    For example, let's say that the RadWindowManager is called RadWindowManager1.
    Then the JavaScript function's name can be set as
    function <%= RadWindowManager1.ClientID %>_close()

    and you can set the OnClientClose property from codebehind (in the user control) like this:
    RadWindowManager1.OnClientClose = RadWindowManager1.ClientID + "_close";

    This way, when the page with the usercontrols in it is rendered, you will get 2 different JavaScript functions, each hooked to the corresponding manager.

    I hope this helps.

    Georgi Tunev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top