Connecting Tech Pros Worldwide Forums | Help | Site Map

Enter Press on Text box ASP.Net

csgraham74
Guest
 
Posts: n/a
#1: Nov 19 '05
Hello,

I wonder if someone could help me.

I have an asp.net form which collects data from a piece of XML and
displays it on screen. If a piece of data is incorrect i will select
the textbox and change the data. If i press enter whilst in the text
box it throws an event.

My question is how do i disable the event or autopostback of the form
when the enter key is pressed whilst in a textbox.

any help greatly appreciated.

CG


Grant Merwitz
Guest
 
Posts: n/a
#2: Nov 19 '05

re: Enter Press on Text box ASP.Net


you can use JavaScript to do this.
Add this code to you TextBox (Where tbMyTextBox is the name of your textbox)

tbMyTextBox.Attributes.Add("onkeydown", "if ((event.which && event.which ==
13) || (event.keyCode && event.keyCode == 13))
{document.Form1.elements['tbMyTextBox].click();return false;} else return
true; ");

HTH


"csgraham74" <csgraham74@hotmail.com> wrote in message
news:1127823326.738444.55560@g49g2000cwa.googlegro ups.com...[color=blue]
> Hello,
>
> I wonder if someone could help me.
>
> I have an asp.net form which collects data from a piece of XML and
> displays it on screen. If a piece of data is incorrect i will select
> the textbox and change the data. If i press enter whilst in the text
> box it throws an event.
>
> My question is how do i disable the event or autopostback of the form
> when the enter key is pressed whilst in a textbox.
>
> any help greatly appreciated.
>
> CG
>[/color]


Grant Merwitz
Guest
 
Posts: n/a
#3: Nov 19 '05

re: Enter Press on Text box ASP.Net


and Form1 was your forms name


"Grant Merwitz" <grant@workshare.com> wrote in message
news:u2fn%23B2wFHA.2252@TK2MSFTNGP09.phx.gbl...[color=blue]
> you can use JavaScript to do this.
> Add this code to you TextBox (Where tbMyTextBox is the name of your
> textbox)
>
> tbMyTextBox.Attributes.Add("onkeydown", "if ((event.which && event.which
> == 13) || (event.keyCode && event.keyCode == 13))
> {document.Form1.elements['tbMyTextBox].click();return false;} else return
> true; ");
>
> HTH
>
>
> "csgraham74" <csgraham74@hotmail.com> wrote in message
> news:1127823326.738444.55560@g49g2000cwa.googlegro ups.com...[color=green]
>> Hello,
>>
>> I wonder if someone could help me.
>>
>> I have an asp.net form which collects data from a piece of XML and
>> displays it on screen. If a piece of data is incorrect i will select
>> the textbox and change the data. If i press enter whilst in the text
>> box it throws an event.
>>
>> My question is how do i disable the event or autopostback of the form
>> when the enter key is pressed whilst in a textbox.
>>
>> any help greatly appreciated.
>>
>> CG
>>[/color]
>
>[/color]


Closed Thread


Similar ASP.NET bytes