how to trap a Enter Key from the Server Side

Posted by Vuyiswamb under JavaScript on 9/16/2010 | Points: 10 | Views : 1930 | Status : [Member] [MVP] [Administrator] | Replies : 2
Good Day all

i have a dummy javascript that can trap for enter key on the client side

function Enterkey()
{
var textb = document.getElementById("<%=TextBox1 %>");
if(window.event.keycode ==13 && textb.value.length > 1)
{
alert('Something will be Returned');
alert(textb.value.length);
}
return false;
}

and on my server side , i am trapping for textlength with something like this

if (TextBox1.Text.Length > 1)
{
//Do whatever
}
elseif(TextBox1.Text.Length > 1 && "And the user Pressed Enter")
{
//do whatever
}

now look at the Elseif part, if the textbox is greater than and the user has pressed the return key(Enter) then it should execute the do whatever condition. i could do this on the client side , but my app requirement has changed so some of the code is on the server side.

how can i achieve this

Thanks

Thank you for posting at Dotnetfunda
[Administrator]



Responses

Posted by: SheoNarayan on: 9/17/2010 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Can you trap the key code in the client side and set the value in the hidden field using JavaScript and in the server side, check for the hidden field value = 13 (in place of "And the user Pressed Enter") in your if condition.

Is this not solve your problem?

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Vuyiswamb, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 9/17/2010 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
Working for people that Changes the App on fly without any documentation its not easy, now i dont need this any more, i am face with the Pagemethods problem

"Because page methods does not follow the normal asp.net page lifecycle , i need to look for another way to call a server side function from the client side."

I will close this post

thanks

Thank you for posting at Dotnetfunda
[Administrator]

Vuyiswamb, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response