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

OnClientLoad - call function with parameters

3 Answers 161 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Hk
Top achievements
Rank 2
Hk asked on 22 Apr 2009, 04:33 PM
Hi,
I have a javascript function "func(a,b,c)". I want to dispatch it on the "onClientLoad" event with the parameters, something like:
onClientLoad="func('paramA','paramB','paramC')";

How can i perform it? since onClientLoad only gets the function name.

Thanks,
Hk

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 Apr 2009, 06:01 AM
Hi,

One suggestion is calling the function func() from the OnClientLoad event handler as shown below.

ASPX:
 
<telerik:RadComboBox ID="RadComboBox2" runat="server" OnClientLoad="OnClientLoad">   
       <Items>   
          . . .                     
       </Items>   
</telerik:RadComboBox>  

JavaScript:
 
<script type="text/javascript"
function OnClientLoad() 
    func(1,2,3); 
function func(a,b,c) 
    alert(a+b+c); 
</script> 

Thanks,
Shinu.
0
Hk
Top achievements
Rank 2
answered on 23 Apr 2009, 06:49 AM
Hi Shiunu,
Thanks, but the problem is I need to generate the onClientLoad call dynamically, to every radcombobox which is on a grid row. therefore, using your solution will create a lot of functions to call them, instead of just calling one function with different parameters.

Do you have any idea for a work around ?
0
ManniAT
Top achievements
Rank 2
answered on 23 Apr 2009, 08:05 PM
Hi,

I guess you know that OnClientLoad get's two parameters.
The first one is the ComboBox itself.
        function OnCLLoad(sender, args) {  
            alert(sender._uniqueId);  
        }  
 
This gives you full access to the client object model.
And (just for an example) you can use (I did once) ToolTip to pass extra information.
--In this case don't forget to reset it in the function :)

So - if it helps - you can "select the action by _uniqueId" or something else like this.

HTH

Manfred
Tags
ComboBox
Asked by
Hk
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Hk
Top achievements
Rank 2
ManniAT
Top achievements
Rank 2
Share this question
or