Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
120
ValueChanged event
posted

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;

parentControl.Controls.Add(numericEdit);

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

Parents
  • 24497
    Suggested Answer
    posted

    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 on
    their 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.

Reply Children
No Data