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

[Solved] Can we pass values to Clientside events?

2 Answers 83 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Iron
Veteran
sitefinitysteve asked on 29 Jan 2010, 02:13 PM
RadRating for example I want to pass over a couple asp control ClientIDs into the Rated event...so I can use them in the external .js code.  Now I cant really find the ids by [id*=] because there might be multiples...

What I've been doing in my other events is setting the OnClientClick in the code behind so I can pass in the ClientIDs I need...

Any ideas? :)
Steve

2 Answers, 1 is accepted

Sort by
0
sitefinitysteve
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 29 Jan 2010, 03:16 PM
Figured it out by adding attributes

So if it helps anyone else
        ratingControl.Attributes.Add("contentid", _contentID); 
        ratingControl.Attributes.Add("panelid", resultPanel.ClientID); 

    //Rad Rating clicked 
    function itemRated(sender, args) { 
        var panel = $find($telerik.$('#' + sender.get_id()).attr('panelid')); //find the XmlHttpPanel 
        if (panel != null) { 
            var contentid = $telerik.$('#' + sender.get_id()).attr('contentid'); //Get contentid 
            var value = 'r:' + sender.get_value() + '|' + contentid; //get rating value to send 
            panel.set_value(value); //send to the XmlHttpPanel 
            sender.set_readOnly(!sender.get_readOnly()); //Disable Rating 
        } 
    } 

0
Dimo
Telerik team
answered on 29 Jan 2010, 03:23 PM
Hi Steve,

ASP.NET AJAX controls do not allow passing of custom attributes to client event handlers, so the developer should think of some other approach, depending on the particular scenario. Glad you have made it. In some other cases one can construct a Javascript array (a dictionary-like) on the server to be used on the client, etc.

All the best,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
sitefinitysteve
Top achievements
Rank 2
Iron
Iron
Veteran
Dimo
Telerik team
Share this question
or