This is a migrated thread and some comments may be shown as answers.

how to differentiate javascript in 2 radwindow in a page

1 Answer 51 Views
Window
This is a migrated thread and some comments may be shown as answers.
ekc ekc
Top achievements
Rank 1
ekc ekc asked on 02 Nov 2010, 08:18 AM
Hi,

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?

Regards.

1 Answer, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 03 Nov 2010, 03:20 PM
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()
{
    alert("called");
}

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.

Regards,
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
Tags
Window
Asked by
ekc ekc
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Share this question
or