I have seen problems about people struggling to get value out of ASPTextBox/server side control. The problem is if they use JavaScript traditional method based on ID
document.getElementById('TextBox_ID').value;
It does not work because the ID of of ASPTextBox control is produced dynamically at runtime and hence JavaScript throws runtime error of null reference as it cannot find any element by that id.
I tried other method that is
document.getElementsByname('TextBox_Name').value;
still did not work for me.
What works?
Inside your ASPTextBox server control set a property called
ClientIDMode="Static".
This ensures that the ID of the element does not chanage on runtime and
voila the JavaScript finds the element using the most commonly
used getelementById method
Cheers
0 comments:
Post a Comment