OnClientLoad - call function with parameters

4 posts, 0 answers
  1. Hk
    Hk avatar
    45 posts
    Member since:
    Nov 2008

    Posted 22 Apr 2009 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 23 Apr 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Hk
    Hk avatar
    45 posts
    Member since:
    Nov 2008

    Posted 23 Apr 2009 Link to this post

    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 ?
  5. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 23 Apr 2009 Link to this post

    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
Back to Top