How to Call JQuery Function from Asp.Net Code Behind
Hi,
I have an asp.net composite control. At load (CreateChilds method) i register my jquery script. This script is in a js file and the file is included in page. Function is written to validate input value to a textbox. Textbox is used to enter page number and i want to allow min 1 and max = pagecount values to enter. Not a successfull version but currently i dont have better here it is; (You may direct me to a better one )
-
function
ValidateTextBoxInputValue(event, elementID, maxValue) { var textBox = document.getElementById(elementID); var currentVal = textBox.value; var currentSelection = parseInt(String.fromCharCode(event.keyCode), 10); if (currentSelection > maxValue) { return false; }
if(currentSelection < 1){ return false; }
return true; }
To call this script, my cs code it below;
-
private
void RegisterScripts() {
string keydownScript = "ValidateTextBoxInputValue(event," + pageTextBox.ClientID + ", " + pageCount.ToString() + ");"; pageTextBox.Attributes.Add(
"OnClientKeyDown", keydownScript); }
Gives no error on page, but dont work.
I use ie debug tool, inserted break point to function and see that there is no hit. What's my mistake ? Thanks.