Wednesday, March 21, 2012

Parameters passing with ClickBehavour

I have read Wilco's post: http://www.wilcob.com/Wilco/Atlas/DeclarativelyInvokingJavaScript.aspx#comments

But still cannot pass a parameter to a function call.

<scriptlanguage="javascript"type="text/javascript">
functoin MyHandler(sender, args) {
var dc = sender.get_dataContext();
var descr = dc.getProperty("Description");
alert(descr);
}
</script>

[...]

<atlas:Button ...>
<ClickHandler="MyHandler"/>
</atlas:Button
is the example, on the page, but I dont get how I can get bind for example an ID to be passed to my function.

Thanks all :)

Hi,

you are using the function as an event handler (for the click event) thus it's normal that you cannot pass parameters to it; only the object that raises the event (the Button instance in this case) should pass parameter to event handlers.

What you could do is retrieve the ID parameter in the event handler. Which are your requirements?
Thanks for your reply :)

I have a datasource retrieved from the web service and is binding it toa list. For each row of the list, there is a "link" where the user canclick on to call the JS function passing in the ID that hopefully canbe binded to.

For example:

Data Source:

Name || ID

Joe Doe || 0
Garbin || 1

And the list will be outputtied as:

<a href="http://links.10026.com/?link=#" onclick=functiontoCall( 0 )> Joe Doe </a>
<a href="http://links.10026.com/?link=#" onclick=functiontoCall( 1 )> Garbin </a
Something similar to the above is what I am trying to do.

Thanks :)

No comments:

Post a Comment