Hi,
I created a Rad Grid dynamically in the VB code behind. Following the procedures in programmatic creation of RadGrid. There are TextBox control in the GridTemplateColumn. I also defined a GridTemplate class with the InstantiateIn method in it. I added the event handler for TextChanged event. I also set the EnableAjax flag of the RadGrid and the AutoPostBack flag of the TextBox to be true. The update of the TextBox works totally fine with the ajaxified feature.
I tried to do a view source after the page is loaded and the TextBox is defined like this:
<input name="_ctl0:ContentPlaceHolder1:_ctl11:_ctl1:_ctl4:txt" type="text" value="90.00" onchange="javascript:setTimeout('RadGridNamespace.AsyncRequest(\'_ctl0$ContentPlaceHolder1$_ctl11$_ctl1$_ctl4$txt\',\'\', \'_ctl0_ContentPlaceHolder1__ctl11\', event)', 0)" onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" language="javascript" id="_ctl0_ContentPlaceHolder1__ctl11__ctl1__ctl4_txt" style="width:70px;text-align:right;" />
Now, my question is, how can I add a javascript function in the "onchange" event of the TextBox? My goal is to use that javascript function to validate the text in the TextBox first, if everything is correct, then move to the TextBox.TextChanged event in the code behind. Is it possible to do something like this after the page is loaded?
<input name="_ctl0:ContentPlaceHolder1:_ctl11:_ctl1:_ctl4:txt" type="text" value="90.00" onchange="javascript:if validateTextBox() then {setTimeout('RadGridNamespace.AsyncRequest(\'_ctl0$ContentPlaceHolder1$_ctl11$_ctl1$_ctl4$txt\',\'\', \'_ctl0_ContentPlaceHolder1__ctl11\', event)', 0)}" onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" language="javascript" id="_ctl0_ContentPlaceHolder1__ctl11__ctl1__ctl4_txt" style="width:70px;text-align:right;" />
I created a Rad Grid dynamically in the VB code behind. Following the procedures in programmatic creation of RadGrid. There are TextBox control in the GridTemplateColumn. I also defined a GridTemplate class with the InstantiateIn method in it. I added the event handler for TextChanged event. I also set the EnableAjax flag of the RadGrid and the AutoPostBack flag of the TextBox to be true. The update of the TextBox works totally fine with the ajaxified feature.
I tried to do a view source after the page is loaded and the TextBox is defined like this:
<input name="_ctl0:ContentPlaceHolder1:_ctl11:_ctl1:_ctl4:txt" type="text" value="90.00" onchange="javascript:setTimeout('RadGridNamespace.AsyncRequest(\'_ctl0$ContentPlaceHolder1$_ctl11$_ctl1$_ctl4$txt\',\'\', \'_ctl0_ContentPlaceHolder1__ctl11\', event)', 0)" onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" language="javascript" id="_ctl0_ContentPlaceHolder1__ctl11__ctl1__ctl4_txt" style="width:70px;text-align:right;" />
Now, my question is, how can I add a javascript function in the "onchange" event of the TextBox? My goal is to use that javascript function to validate the text in the TextBox first, if everything is correct, then move to the TextBox.TextChanged event in the code behind. Is it possible to do something like this after the page is loaded?
<input name="_ctl0:ContentPlaceHolder1:_ctl11:_ctl1:_ctl4:txt" type="text" value="90.00" onchange="javascript:if validateTextBox() then {setTimeout('RadGridNamespace.AsyncRequest(\'_ctl0$ContentPlaceHolder1$_ctl11$_ctl1$_ctl4$txt\',\'\', \'_ctl0_ContentPlaceHolder1__ctl11\', event)', 0)}" onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" language="javascript" id="_ctl0_ContentPlaceHolder1__ctl11__ctl1__ctl4_txt" style="width:70px;text-align:right;" />