Hello,
I've recently upgraded an existing project to NetAdvantage 2009 v2. I've been dynamically creating WebNumericEdit controls, setting their client-side event properties, and adding them to the page programatically. For example, I had a section in my code that did the following:
WebNumericEdit numericEdit = new WebNumericEdit() { ID = id };
numericEdit.ClientSideEvents.ValueChange = onChangeScript;
parentControl.Controls.Add(numericEdit);
I'd like to take advantage of the new controls in the Aikido framework in order to achieve better performance (some pages end up with a large number of dynamic controls on them). So I changed the code to look like this:
WebNumericEditor numericEdit = new WebNumericEditor() { ID = id };
numericEdit.ClientEvents.ValueChanged = onChangeScript;
The problem is that now, when the second line runs, I get the following exception: "Value should contain the name of a javascript function. Space, quote, parenthesis, etc. characters are not allowed."
I understand the meaning of the exception perfectly. However, I really need the javascript code that fires when the value of the numeric editor is changed to be more than just the name of a javascript function (it is dynamically generated). This was never a problem before, so I don't understand what the problem is now.
Is there any way in the new framework that I can achieve the same effect that I could get previously?
Thanks,
Ken
Hi Ken,
If I understood your problem correctly, then the string onChangeScript contains javascript statements.That is not a standard usage of ClientSideEvents of WebNumericEdit, though, that special option is supported.The client side event model of WebNumericEditor and all Infragistics.Web.UI controls is based ontheir AJAX base class, which does not have such extended option and allows only name of function.You may still use your dynamically generated functionality, however, you should wrap it into a function,register that javascript block with ScriptManager and assign to ValueChanged property the name of that function.Note: the syntax of ajax client side handlers is following:function anyClientSideEventFunctionName(sender, evtArgs){}Where sender is reference to javascript object: "owner" control. In your case it will be WebNumericEditor.evtArgs is instance of class which provides specific/extra information about event.
Of course both parameters are optional.
I just can't believe this. What it is good all your fancy looking control if they can't handle a simple task like passing an argument in a javascript function; something that the most basic html controls can do. At least you should provide a working example on how to accomplish the task !