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
2320
WebDateTimeEdit.ClientSideEvents.ValueChange question
posted

This one is out there but I thought I would ask.

In our web application, we have functionality that monitors whether data has been modified or not via clientside javascript code by setting a flag to true or false.

On the server side, we have an overloaded function called MonitorChanges(WebDateTimeEdit ctrl).

THe purpose of the function is basically to inject this script block "setModified(true);".  In the case of the webdatetimeedit I use the valuechange event.

In the function, we check the clientside.ValueChange, if its empty, we set it equal to setModified(true); if however it isn't empty we first search for setModified and if its not there, we append it to the existing text.  So ClientSide.ValueChange ends up being equal to this

 "setModified(true);valueChangedScript"

This is done incase someone has already implemented a clientside javascript event.  For some Infragistics controls, this works fine.  I tested it by implenting the event via clientside code, and also on the server calling MonitorChanges(control) to append the setModified(true) function call.  For some reason, the WebDateTimeEdit however won't work.  It is successfully calling the setModified(true) block but it isn't calling the second JavaScript function?

Obviously, I can just put the setModified(true); into the existing script block, and remove the server-side call to MonitorChanges but I was hoping to stay consistent.  Do any of the client-side javascript guru's know why some infragistics controls let me have multiple function calls attached to the clientside event and some don't? 

Here is the code for the function (not that it will really matter)

if (string.IsNullOrEmpty(dte.ClientSideEvents.ValueChange))
{
    // does not already contain script, so add modified script 
    dte.ClientSideEvents.ValueChange = ConstUi.SET_MODIFIED_SCRIPT;
}
else
{
    // ValueChange is already implemented, add set modified script if its not there yet
    string sScript = dte.ClientSideEvents.ValueChange;
    if (!sScript.Contains(ConstUi.SET_MODIFIED_SCRIPT))
        dte.ClientSideEvents.ValueChange = string.Format("{0}{1}", ConstUi.SET_MODIFIED_SCRIPT, sScript);

}
 

  • 24497
    posted

    Hi,

    That is not clear what you are doing. It looks like that you try to set value for ClientSideEvents.AMember to a javascript statement. If that is correct, then I am doubt that all other controls support that. The ClientSideEvents is designed to contain only a single name to function (no spaces, brackets, etc.). However, some controls allow to set value to a javascript statement (mostly for a debug purpose or very simple operation). Of course you can not mix statement with a function name, you probably will get exception.

    Actually WebTextEdit supports multiple listeners to all its events. For example, if you want to dynamically add another listener to ClientSideEvents.ValueChange, then you may use addEventListener(name,fRef,obj) at any time. To remove, there is removeEventListener(name,fRef). For example, within ClientSideEvents.Initialize write following:

    function myFunction(optionalObj)
    {
      alert(
    'optionalObj='+optionalObj);
    }

    function webTextEdit1_Initialize(oEdit, text)
    {
     
    oEdit.addEventListener('valuechange', myFunction, 'optional object');
    }