473,320 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Stop AutoPostBack

ASP.NET 2.0
Visual Studio 2008

I have the following code and when the textbox displays and I press Enter
while in the text box I get AutoPostBack, how do I stop AutoPostBack?

TextBox txt = new TextBox();
txt.MaxLength = parm.MaxLength;
txt.ID = parm.ParameterNameID;
txt.Text = "12345";
txt.EnableViewState = true;
txt.AutoPostBack = false;
this.PlaceHolder1.Controls.Add(txt);

Thank You
Peter
Mar 4 '08 #1
6 4827
Never mind, it's working, I don't know why it did not work before.

"Peter" <pc*****@nospam.nospamwrote in message
news:ui**************@TK2MSFTNGP02.phx.gbl...
ASP.NET 2.0
Visual Studio 2008

I have the following code and when the textbox displays and I press Enter
while in the text box I get AutoPostBack, how do I stop AutoPostBack?

TextBox txt = new TextBox();
txt.MaxLength = parm.MaxLength;
txt.ID = parm.ParameterNameID;
txt.Text = "12345";
txt.EnableViewState = true;
txt.AutoPostBack = false;
this.PlaceHolder1.Controls.Add(txt);

Thank You
Peter

Mar 4 '08 #2
ASP.NET 2.0
Visual Studio 2008

I have the following code and when the textbox displays and I press Enter
while in the text box I get AutoPostBack, how do I stop AutoPostBack?

If I add another textbox (not in the PlaceHoder) the AutoPostback does get
disabled in the txt control, but if there are no other text boxes on the
form the txt control allways does the AutoPostback
TextBox txt = new TextBox();
txt.MaxLength = parm.MaxLength;
txt.ID = parm.ParameterNameID;
txt.Text = "12345";
txt.EnableViewState = true;
txt.AutoPostBack = false;
this.PlaceHolder1.Controls.Add(txt);

"Peter" <pc*****@nospam.nospamwrote in message
news:ug**************@TK2MSFTNGP02.phx.gbl...
Never mind, it's working, I don't know why it did not work before.

"Peter" <pc*****@nospam.nospamwrote in message
news:ui**************@TK2MSFTNGP02.phx.gbl...
>ASP.NET 2.0
Visual Studio 2008

I have the following code and when the textbox displays and I press Enter
while in the text box I get AutoPostBack, how do I stop AutoPostBack?

TextBox txt = new TextBox();
txt.MaxLength = parm.MaxLength;
txt.ID = parm.ParameterNameID;
txt.Text = "12345";
txt.EnableViewState = true;
txt.AutoPostBack = false;
this.PlaceHolder1.Controls.Add(txt);

Thank You
Peter


Mar 4 '08 #3
On 4 âÅÒ, 07:33, "Peter" <pczu...@nospam.nospamwrote:
I have the following code and when the textbox displays and I press Enter
while in the text box I get AutoPostBack, how do I stop AutoPostBack?
Hi Peter,

This behaviour is not caused by value of AutoPostBack property of a
TextBox, it is default browser's reaction to pressing Enter key.
I posted some thoughts on this topic here:
http://marss.co.ua/UnexpectedPostback.aspx
Maybe you'll find it useful.

Regards,
Mykola
http://marss.co.ua
Mar 4 '08 #4
Thank you very much!

It certainly explains what was going on.
"Peter" <pc*****@nospam.nospamwrote in message
news:ui**************@TK2MSFTNGP02.phx.gbl...
ASP.NET 2.0
Visual Studio 2008

I have the following code and when the textbox displays and I press Enter
while in the text box I get AutoPostBack, how do I stop AutoPostBack?

TextBox txt = new TextBox();
txt.MaxLength = parm.MaxLength;
txt.ID = parm.ParameterNameID;
txt.Text = "12345";
txt.EnableViewState = true;
txt.AutoPostBack = false;
this.PlaceHolder1.Controls.Add(txt);

Thank You
Peter

Mar 4 '08 #5
I have tried the Convenience #1 Item #3 from the
http://marss.co.ua/UnexpectedPostback.aspx but the page still gets submitted
when I press the enter key and the focus is in the text box. Regardless how
many Textboxes or Input fields I have on the webpage, pressing Enter key
submits the page.

The only time I can get it to work is if I use UseSubmitBehavior="False",
but then FCKEditor control does not post it's value, so I can not use that.

Any other suggestions I can try?

"marss" <ma******@gmail.comwrote in message
news:e8**********************************@2g2000hs n.googlegroups.com...
On 4 âÅÒ, 07:33, "Peter" <pczu...@nospam.nospamwrote:
I have the following code and when the textbox displays and I press
Enter
while in the text box I get AutoPostBack, how do I stop AutoPostBack?
Hi Peter,

This behaviour is not caused by value of AutoPostBack property of a
TextBox, it is default browser's reaction to pressing Enter key.
I posted some thoughts on this topic here:
http://marss.co.ua/UnexpectedPostback.aspx
Maybe you'll find it useful.

Regards,
Mykola
http://marss.co.ua
Jun 27 '08 #6
I have tried the Convenience #1 Item #3 from thehttp://marss.co.ua/UnexpectedPostback.aspxbut the page still gets submitted
when I press the enter key and the focus is in the text box. Regardless how
many Textboxes or Input fields I have on the webpage, pressing Enter key
submits the page.

The only time I can get it to work is if I use UseSubmitBehavior="False",
but then FCKEditor control does not post it's value, so I can not use that.
Two different situations are described there, and the attempt to solve
situation #2 by one of the solutions for situation #1 is not very good
idea.

As I see you can avoid the postback if you set
btnSubmit.UseSubmitBehavior="False", where btnSubmit is a button which
submits the form to the server.
Concerning output HTML it is replacement of <input type='submit'by
<input type='button'>. If you want <input type='button'also submits
the form
you have to add a handler for onclick event:

btnSubmit.Attributes["onclick"] = "document.forms[0].submit();"

Try, maybe it will help. That is all that I can suggest, I do not
familiar with FCKEditor and can't give more concrete advice.

Mykola
http://marss.co.ua
Jun 27 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Susan van Houen | last post by:
Hi All, How do I intercept an autopostback on the client side and prevent it from executing the submit? In classic ASP I used to intercept the on_submit and just return false;
8
by: Matthew Louden | last post by:
why need to set autopostback property to be true?? I know autopostback event means to send the form to the server automatically. I tried checkbox, checkbox list, radio button, and radio button...
4
by: Scott M. | last post by:
If I put RequiredFiledValidators on a page and set them up with corresponding TextBoxes everything works just fine. If I add a DropDownList and set its AutoPostBack to True, I am able to post data...
6
by: Sunil | last post by:
Dear All I am a bit confused about AutoPost Back. My concept about AutoPostBack is that If AutoPostBack i "TRUE" for a Web Form the Web Form Goes back to the server and displays a fresh copy of...
3
by: Maverick | last post by:
I have a javascript checking on a search button which is used to check if the dummy value is inputted before the search button is clicked. ===============================================...
2
by: Tom Edelbrok | last post by:
Question: Why does a button event (ie: Button1_Click) get executed on the first click for a textbox control which has 'autopostback=false', but doesn't get executed until a second click when...
2
by: rn5a | last post by:
Assume that a user control has a TextBox (Page1.ascx) <asp:TextBox ID="txtName" runat="server"/> I am encapsulating the above user control in a ASPX page named Page1.aspx i.e. the ASPX page...
0
by: andy | last post by:
Hi, I have a form uses several dropdownlists to narrow a set of criteria. ( This is in turn used to control what is shown on a gridview. ) With each, the user selects an entry and then the next...
1
by: mark4asp | last post by:
How can I stop a post back from firing when there is no need for it to? I have a GridView pager template (shown below): There are 3 commands: ddlPager_SelectedIndexChanged - move the page to...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.