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

Javascript and radAjaxPanel in WebUserControl

2 Answers 54 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Davide
Top achievements
Rank 1
Davide asked on 13 Mar 2009, 08:49 AM
Hi,
I've created a WebUserControl (called myWebCombo) in VB.Net with a RadAjaxPanel inside.
I use this function:

function DoSomething(item){
    <%= ajComboBox.ClientID %>.AjaxRequest(item.ComboBox.GetValue());
}

I've added 2 of my WebUserControl into an ASP.net page and when I run it...this function is repeated and It doesn't work correctly.

In HTML page this is the result:

[..code..]

function DoSomething(item){
    myWebCombo1_ajComboBox.AjaxRequest(item.ComboBox.GetValue());
}

function DoSomething(item){
    myWebCombo2_ajComboBox.AjaxRequest(item.ComboBox.GetValue());
}

so when I change in the first (myWebCombo1), fires the second one!!!!

Thanks a lot!!
Davide Martini

2 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 16 Mar 2009, 05:24 PM
Hello Davide,

This is expected behavior. When the methods has equal names, the last registered will be executed every time.
If you need to have different methods for each User Control, you will need to manage this for yourself.
Here is a code snippet showing how you can achieve the required functionality:
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"
    <script type="text/javascript"
        function <%=this.ClientID %>_DoSomething(sender, args) { 
            debugger
            $find("<%=RadAjaxPanel1.ClientID %>").ajaxRequest(args.get_item().get_value()); 
        } 
    </script> 
</telerik:RadScriptBlock> 
   protected override void OnInit(EventArgs e) 
    { 
        RadComboBox1.OnClientSelectedIndexChanged = this.ClientID + "_DoSomething"
        base.OnInit(e); 
    } 

Regards,
Georgi Krustev
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Davide
Top achievements
Rank 1
answered on 18 Mar 2009, 02:42 PM
Hi Georgi,
It works!!!!

Thank you very much.

Bye
Davide M.
Tags
General Discussions
Asked by
Davide
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Davide
Top achievements
Rank 1
Share this question
or