Showing posts with label return. Show all posts
Showing posts with label return. Show all posts

Thursday, March 22, 2012

Textarea, form submit on return key

Hi,

Something is causing the form to be submitted whenever I hit the
return-key. Normally I wouldn't bother, but it also happens when I'm
typing in a textarea-control, which makes it impossible to fill in
multiple lines...

Where to look?

Thanks!Sjaakie schreef:
> Hi,
> Something is causing the form to be submitted whenever I hit the
> return-key. Normally I wouldn't bother, but it also happens when I'm
> typing in a textarea-control, which makes it impossible to fill in
> multiple lines...
> Where to look?
> Thanks!

It might be helpfull to know that the textarea is a multiline
textbox-control.

Cheers
Sjaakie, i tried a small sample but I can't reproduce the behavior!, can you
post some code?

Jose
"Sjaakie" <keep@.secret.it> wrote in message
news:448fd04d$0$31641$e4fe514c@.news.xs4all.nl...
> Sjaakie schreef:
>> Hi,
>>
>> Something is causing the form to be submitted whenever I hit the
>> return-key. Normally I wouldn't bother, but it also happens when I'm
>> typing in a textarea-control, which makes it impossible to fill in
>> multiple lines...
>>
>> Where to look?
>>
>> Thanks!
> It might be helpfull to know that the textarea is a multiline
> textbox-control.
> Cheers
Jose Rodriguez schreef:
> Sjaakie, i tried a small sample but I can't reproduce the behavior!, can you
> post some code?
> Jose
> "Sjaakie" <keep@.secret.it> wrote in message
> news:448fd04d$0$31641$e4fe514c@.news.xs4all.nl...
>> Sjaakie schreef:
>>> Hi,
>>>
>>> Something is causing the form to be submitted whenever I hit the
>>> return-key. Normally I wouldn't bother, but it also happens when I'm
>>> typing in a textarea-control, which makes it impossible to fill in
>>> multiple lines...
>>>
>>> Where to look?
>>>
>>> Thanks!
>> It might be helpfull to know that the textarea is a multiline
>> textbox-control.
>>
>> Cheers

Jose,
I tried to cancel this posting, but apparently it was already replicated
to other servers.

It turned out it was just me being stupid. I was confident I had set the
property 'Multiline', but I didn't ... so it behaved as a regular textbox.

Thanks for your support anyway.

Cheers,
Sjaak

Textarea, form submit on return key

Hi,
Something is causing the form to be submitted whenever I hit the
return-key. Normally I wouldn't bother, but it also happens when I'm
typing in a textarea-control, which makes it impossible to fill in
multiple lines...
Where to look?
Thanks!Sjaakie schreef:
> Hi,
> Something is causing the form to be submitted whenever I hit the
> return-key. Normally I wouldn't bother, but it also happens when I'm
> typing in a textarea-control, which makes it impossible to fill in
> multiple lines...
> Where to look?
> Thanks!
It might be helpfull to know that the textarea is a multiline
textbox-control.
Cheers
Sjaakie, i tried a small sample but I can't reproduce the behavior!, can you
post some code?
Jose
"Sjaakie" <keep@.secret.it> wrote in message
news:448fd04d$0$31641$e4fe514c@.news.xs4all.nl...
> Sjaakie schreef:
> It might be helpfull to know that the textarea is a multiline
> textbox-control.
> Cheers
Jose Rodriguez schreef:
> Sjaakie, i tried a small sample but I can't reproduce the behavior!, can y
ou
> post some code?
> Jose
> "Sjaakie" <keep@.secret.it> wrote in message
> news:448fd04d$0$31641$e4fe514c@.news.xs4all.nl...
>
Jose,
I tried to cancel this posting, but apparently it was already replicated
to other servers.
It turned out it was just me being stupid. I was confident I had set the
property 'Multiline', but I didn't ... so it behaved as a regular textbox.
Thanks for your support anyway.
Cheers,
Sjaak

textBox

in C# for asp. i have a textbox, and at the point of doing an INSERT to my
table, it is cutting it off at the point where end users press Return (the
next line).

in other words, in a multiline textbox which allows up to 4000 characters,
if the end users presses a key to go to the next line it doesn't add the next
line to sql?

stringbuilder has my comments something like:
string myComments = "123456789 are my numbers/nBut here the line is broken"
/n is where it stops. i'm sure doing a replace for this will fix it, but is
there a better way?How do you know it is cutting off your string? Are you looking at in in
Enterprise Manager or when your content renders?

"ae" <ae@.discussions.microsoft.com> wrote in message
news:CF42C75A-C2ED-4169-BE86-B0928AE3EBCC@.microsoft.com...
> in C# for asp. i have a textbox, and at the point of doing an INSERT to
> my
> table, it is cutting it off at the point where end users press Return (the
> next line).
> in other words, in a multiline textbox which allows up to 4000 characters,
> if the end users presses a key to go to the next line it doesn't add the
> next
> line to sql?
> stringbuilder has my comments something like:
> string myComments = "123456789 are my numbers/nBut here the line is
> broken"
> /n is where it stops. i'm sure doing a replace for this will fix it, but
> is
> there a better way?
Both.

In enterprise Mgr. i only get the first 16 characters. I did two changes
and it fixed it, i had the field type set as text with the default of 16.
that might of caused it, but I doubt it since it only had 4 characters at one
point.

it's corrected now, I changed the field to nvarchar from text in sql, and
with a stringbuilder used something like: strInput = Replace("\n", (" ")
and did another for the "\r". All is well.

"Peter Rilling" wrote:

> How do you know it is cutting off your string? Are you looking at in in
> Enterprise Manager or when your content renders?
> "ae" <ae@.discussions.microsoft.com> wrote in message
> news:CF42C75A-C2ED-4169-BE86-B0928AE3EBCC@.microsoft.com...
> > in C# for asp. i have a textbox, and at the point of doing an INSERT to
> > my
> > table, it is cutting it off at the point where end users press Return (the
> > next line).
> > in other words, in a multiline textbox which allows up to 4000 characters,
> > if the end users presses a key to go to the next line it doesn't add the
> > next
> > line to sql?
> > stringbuilder has my comments something like:
> > string myComments = "123456789 are my numbers/nBut here the line is
> > broken"
> > /n is where it stops. i'm sure doing a replace for this will fix it, but
> > is
> > there a better way?
>

Tuesday, March 13, 2012

textBox

in C# for asp. i have a textbox, and at the point of doing an INSERT to my
table, it is cutting it off at the point where end users press Return (the
next line).
in other words, in a multiline textbox which allows up to 4000 characters,
if the end users presses a key to go to the next line it doesn't add the nex
t
line to sql?
stringbuilder has my comments something like:
string myComments = "123456789 are my numbers/nBut here the line is broken"
/n is where it stops. i'm sure doing a replace for this will fix it, but is
there a better way?How do you know it is cutting off your string? Are you looking at in in
Enterprise Manager or when your content renders?
"ae" <ae@.discussions.microsoft.com> wrote in message
news:CF42C75A-C2ED-4169-BE86-B0928AE3EBCC@.microsoft.com...
> in C# for asp. i have a textbox, and at the point of doing an INSERT to
> my
> table, it is cutting it off at the point where end users press Return (the
> next line).
> in other words, in a multiline textbox which allows up to 4000 characters,
> if the end users presses a key to go to the next line it doesn't add the
> next
> line to sql?
> stringbuilder has my comments something like:
> string myComments = "123456789 are my numbers/nBut here the line is
> broken"
> /n is where it stops. i'm sure doing a replace for this will fix it, but
> is
> there a better way?
Both.
In enterprise Mgr. i only get the first 16 characters. I did two changes
and it fixed it, i had the field type set as text with the default of 16.
that might of caused it, but I doubt it since it only had 4 characters at on
e
point.
it's corrected now, I changed the field to nvarchar from text in sql, and
with a stringbuilder used something like: strInput = Replace("\n", (" ")
and did another for the "\r". All is well.
"Peter Rilling" wrote:

> How do you know it is cutting off your string? Are you looking at in in
> Enterprise Manager or when your content renders?
> "ae" <ae@.discussions.microsoft.com> wrote in message
> news:CF42C75A-C2ED-4169-BE86-B0928AE3EBCC@.microsoft.com...
>
>

TextBox and Button

Hey guys...
In my aspx page I have a textbox that when the user press Return I need to
click a button. How can I do it?
OR
All the pages that contains buttons have a default button, but I don't know
how to define the default button. If I do it, my problem will be solved.
Thank'shttp://www.dotnetspider.com/Technol...px?SampleId=212
"Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
news:u9d7HtyUEHA.2692@.TK2MSFTNGP09.phx.gbl...
> Hey guys...
> In my aspx page I have a textbox that when the user press Return I need to
> click a button. How can I do it?
> OR
> All the pages that contains buttons have a default button, but I don't
> know
> how to define the default button. If I do it, my problem will be solved.
>
> Thank's
>
Hy Ken
I make this:
<asp:textbox id="txtEntrPrCB" onKeyDown="KeyDownHandler('btnEntrPrMa')"
.....
But when I press Enter, I receive this error:
Object doesn't suport this property or method.
WHY'? What I'm doing wrong?
Thank's
"Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> escreveu na mens
agem
news:OFjqo8yUEHA.2668@.TK2MSFTNGP10.phx.gbl...
> http://www.dotnetspider.com/Technol...px?SampleId=212
> "Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
> news:u9d7HtyUEHA.2692@.TK2MSFTNGP09.phx.gbl...
to
>
There may be some errant spaces in the code.
How about this?
Ken
<!-->
<%@. Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript">
function KeyDownHandler(btn)
{
// process only the Enter key
if (event.keyCode == 13)
{
// cancel the default submit
event.returnValue=false;
event.cancel = true;
// submit the form by programmatically clicking the specified
button
alert('Clicked');
btn.click();
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button Runat="server" ID="DefButton" />
<asp:TextBox Runat="server" ID="FirstName"
onKeyDown="KeyDownHandler(DefButton)" />
</div>
</form>
</body>
</html>
<!-->
"Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
news:OWahAJzUEHA.2716@.tk2msftngp13.phx.gbl...
> Hy Ken
> I make this:
> <asp:textbox id="txtEntrPrCB" onKeyDown="KeyDownHandler('btnEntrPrMa')"
> .....
> But when I press Enter, I receive this error:
> Object doesn't suport this property or method.
>
> WHY'? What I'm doing wrong?
>
> Thank's
>
> "Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> escreveu na
> mensagem
> news:OFjqo8yUEHA.2668@.TK2MSFTNGP10.phx.gbl...
> to
>
Andre,
The code Ken gave you will work, but event.KeyCode will only work for IE and
not netscape. If you want to, I have a bunch of useful javascripts all
rolled into a single component on my website, www.aboutfortunate.com. Click
the code library link on the top right of the page and then click the
javascript button in the menu on the left.
All code on my site is free and the full .NET v1.1 project is downloadable.
So even if you don't want to use the object as is you can get some decent
code examples from it.
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
news:OWahAJzUEHA.2716@.tk2msftngp13.phx.gbl...
> Hy Ken
> I make this:
> <asp:textbox id="txtEntrPrCB" onKeyDown="KeyDownHandler('btnEntrPrMa')"
> .....
> But when I press Enter, I receive this error:
> Object doesn't suport this property or method.
>
> WHY'? What I'm doing wrong?
>
> Thank's
>
> "Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> escreveu na
mensagem
> news:OFjqo8yUEHA.2668@.TK2MSFTNGP10.phx.gbl...
need
> to
solved.
>
hy
here is some code snippet:
--
put next code in Page_Load
TextBox1.Attributes.Add("onkeypress",
"if(event.keyCode==65)Form1.Button1.onclick();")
when you press 'A' in TextBox,preseding code excute
You can intercept the client side enter keypress event of the text box and
then do what you want using javascript code.
Here's a good example:
http://www.kamp-hansen.dk/pages/sho...id=21&menuid=18
You could also try using this free control.
http://www.metabuilders.com/tools/DefaultButtons.aspx
And here's a couple good articles on the subject:
http://www.allasp.net/enterkey.aspx
http://www.aspnetpro.com/features/2...p200406so_f.asp
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
news:u9d7HtyUEHA.2692@.TK2MSFTNGP09.phx.gbl...
> Hey guys...
> In my aspx page I have a textbox that when the user press Return I need to
> click a button. How can I do it?
> OR
> All the pages that contains buttons have a default button, but I don't
know
> how to define the default button. If I do it, my problem will be solved.
>
> Thank's
>

TextBox and Button

Hey guys...

In my aspx page I have a textbox that when the user press Return I need to
click a button. How can I do it?

OR

All the pages that contains buttons have a default button, but I don't know
how to define the default button. If I do it, my problem will be solved.

Thank'shttp://www.dotnetspider.com/Technol...px?SampleId=212

"Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
news:u9d7HtyUEHA.2692@.TK2MSFTNGP09.phx.gbl...
> Hey guys...
> In my aspx page I have a textbox that when the user press Return I need to
> click a button. How can I do it?
> OR
> All the pages that contains buttons have a default button, but I don't
> know
> how to define the default button. If I do it, my problem will be solved.
>
> Thank's
Hy Ken

I make this:

<asp:textbox id="txtEntrPrCB" onKeyDown="KeyDownHandler('btnEntrPrMa')"
......

But when I press Enter, I receive this error:

Object doesn't suport this property or method.

WHY??? What I'm doing wrong?

Thank's

"Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> escreveu na mensagem
news:OFjqo8yUEHA.2668@.TK2MSFTNGP10.phx.gbl...
> http://www.dotnetspider.com/Technol...px?SampleId=212
> "Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
> news:u9d7HtyUEHA.2692@.TK2MSFTNGP09.phx.gbl...
> > Hey guys...
> > In my aspx page I have a textbox that when the user press Return I need
to
> > click a button. How can I do it?
> > OR
> > All the pages that contains buttons have a default button, but I don't
> > know
> > how to define the default button. If I do it, my problem will be solved.
> > Thank's
There may be some errant spaces in the code.

How about this?

Ken

<!--->
<%@. Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript">
function KeyDownHandler(btn)
{
// process only the Enter key
if (event.keyCode == 13)
{
// cancel the default submit
event.returnValue=false;
event.cancel = true;
// submit the form by programmatically clicking the specified
button
alert('Clicked');
btn.click();
}
}
</script
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button Runat="server" ID="DefButton" />
<asp:TextBox Runat="server" ID="FirstName"
onKeyDown="KeyDownHandler(DefButton)" />
</div>
</form>
</body>
</html>
<!---
"Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
news:OWahAJzUEHA.2716@.tk2msftngp13.phx.gbl...
> Hy Ken
> I make this:
> <asp:textbox id="txtEntrPrCB" onKeyDown="KeyDownHandler('btnEntrPrMa')"
> .....
> But when I press Enter, I receive this error:
> Object doesn't suport this property or method.
>
> WHY??? What I'm doing wrong?
>
> Thank's
>
> "Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> escreveu na
> mensagem
> news:OFjqo8yUEHA.2668@.TK2MSFTNGP10.phx.gbl...
>> http://www.dotnetspider.com/Technol...px?SampleId=212
>>
>> "Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
>> news:u9d7HtyUEHA.2692@.TK2MSFTNGP09.phx.gbl...
>> > Hey guys...
>>> > In my aspx page I have a textbox that when the user press Return I need
> to
>> > click a button. How can I do it?
>>> > OR
>>> > All the pages that contains buttons have a default button, but I don't
>> > know
>> > how to define the default button. If I do it, my problem will be
>> > solved.
>>>> > Thank's
>>>>
Andre,

The code Ken gave you will work, but event.KeyCode will only work for IE and
not netscape. If you want to, I have a bunch of useful javascripts all
rolled into a single component on my website, www.aboutfortunate.com. Click
the code library link on the top right of the page and then click the
javascript button in the menu on the left.

All code on my site is free and the full .NET v1.1 project is downloadable.
So even if you don't want to use the object as is you can get some decent
code examples from it.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
news:OWahAJzUEHA.2716@.tk2msftngp13.phx.gbl...
> Hy Ken
> I make this:
> <asp:textbox id="txtEntrPrCB" onKeyDown="KeyDownHandler('btnEntrPrMa')"
> .....
> But when I press Enter, I receive this error:
> Object doesn't suport this property or method.
>
> WHY??? What I'm doing wrong?
>
> Thank's
>
> "Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> escreveu na
mensagem
> news:OFjqo8yUEHA.2668@.TK2MSFTNGP10.phx.gbl...
> > http://www.dotnetspider.com/Technol...px?SampleId=212
> > "Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
> > news:u9d7HtyUEHA.2692@.TK2MSFTNGP09.phx.gbl...
> > > Hey guys...
> > > > In my aspx page I have a textbox that when the user press Return I
need
> to
> > > click a button. How can I do it?
> > > > OR
> > > > All the pages that contains buttons have a default button, but I don't
> > > know
> > > how to define the default button. If I do it, my problem will be
solved.
> > > > > Thank's
> >
hy
here is some code snippet:
-----------
put next code in Page_Load
TextBox1.Attributes.Add("onkeypress",
"if(event.keyCode==65)Form1.Button1.onclick();")
when you press 'A' in TextBox,preseding code excute
You can intercept the client side enter keypress event of the text box and
then do what you want using javascript code.
Here's a good example:
http://www.kamp-hansen.dk/pages/sho...id=21&menuid=18

You could also try using this free control.
http://www.metabuilders.com/tools/DefaultButtons.aspx

And here's a couple good articles on the subject:
http://www.allasp.net/enterkey.aspx
http://www.aspnetpro.com/features/2...p200406so_f.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"Andr Almeida Maldonado" <deweb@.bol.com.br> wrote in message
news:u9d7HtyUEHA.2692@.TK2MSFTNGP09.phx.gbl...
> Hey guys...
> In my aspx page I have a textbox that when the user press Return I need to
> click a button. How can I do it?
> OR
> All the pages that contains buttons have a default button, but I don't
know
> how to define the default button. If I do it, my problem will be solved.
>
> Thank's