Having some pain with this event, I have some code like this for a dropdown:
return helper.DropDownList(data.ModelEntityId.ToString(), selectList, "<Select>", new { onChange = onChange });
where onChange is a variable containing a javascript function to run, this works great. However with the textbox version (below) the onchange event is fired when the page loads (unlike the DropdownList, different behavior is annoying). When the javascript function is called at the time the page is loading I get the error: Javascript "undefined" could not be found... (it then works subsequently)
return helper.TextBox(data.ModelEntity.ModelEntityId.ToString(), data.ValueText, new { onchange = onChange });
Example javascript
function SuitabilityChecked(providerId, checkId, parentId) {
alert("meep"); // just to test error still occurs
};
Is there a different event I should use for a textbox, or something "special I need to do?