How to restrict page from posting back

Suppose you have form on which many textbox are placed and there is a one submit button also in the end. now the problem is if u hit enter key while focusing any textbox, the page will post back no matter what may be the value of autopostback property.

Solution is so simple just make the UseSubmitBehavior property to false.

UseSubmitBehavior = "false"



Author: Alwyn Duraisingh27 Jan 2010 Member Level: Gold   Points : 0


can you tell me in which place i have to set this?

I mean, In the OnSubmit button property or on the aspx page header?

Author: Developer18 Feb 2010 Member Level: Gold   Points : 0

hi amela,

directly we change the properties window autopostback=false.

it may works. try this


Author: Jayendra Kumar19 Feb 2010 Member Level: Gold   Points : 1

Thanks to share this information but i think you set autopostback = false then it works.

Author: shashi shekhar02 Apr 2010 Member Level: Bronze   Points : 2

See .txt File for this solution ..

Author: shashi shekhar02 Apr 2010 Member Level: Bronze   Points : 0

To Stop The Post Back of Page
use Ajax Controls

See Given txt File here..

Author: Ultimaterengan18 Jun 2010 Member Level: Gold   Points : 1

I tried this one but its not working well.Can you give me one example for this.

Author: venkii18 Aug 2010 Member Level: Silver   Points : 1


tell me where can i use that code. currently in my application i have the same problem.

Thanks in advance........

Author: Vijil18 Aug 2010 Member Level: Gold   Points : 0

Do "IsPostBack" property is "False"

Author: arun kumar16 Sep 2010 Member Level: Silver   Points : 1

set the submit button property of UseSubmitBehavior False and also set AutoBoxproperty of all textbox false that would sort your problem.Can you tell me about the textbox property also ..........
i think you want to maintain the scroll position for the large web page you can use on of these methods :

1- use Web.config page section

(-: this will maintains the scroll positions for all the web site pages.:-)

2- in the page declaration <%@ Page (-:MaintainScrollPositionOnPostback="true" %> : this will maintains the scroll position for this page only.:-)

3- programmatically from code behind System.Web.UI.Page.MaintainScrollPositionOnPostBack = true;
(-: this will maintains the scroll position for this page only (the same as page declration):-)

Author: Maheshbabu11 Oct 2010 Member Level: Bronze   Points : 1

I think its work.........

Under page load:
if (!Page.IsPostBack)

4 this.textEnterPostBack.Attributes.Add("OnKeyDown", "return (event.keyCode!=13);");

Author: syed nasir hussain07 Apr 2011 Member Level: Silver   Points : 0

use ajax control will not postback

Author: Pankaj Rajput19 May 2011 Member Level: Gold   Points : 1

You can not restrict a page posting back by setting UseSubmitBehaviour property to False.

Rather you should be clear about the UseSubmitBehaviour property.

The UseSubmitBehavior property specifies if the Button control uses the browser's built-in submit function or the ASP.NET postback mechanism.

This property is set to TRUE if the control uses the browser's submit function. FALSE otherwise. Default value is TRUE.

When set to FALSE, ASP.NET adds a client-side script to post the form. This enables control developers to use the GetPostBackEventReference method to return the client postback event for the Button.

Guest Author: Saju20 Feb 2012

See my reply to Judy, . I'm with you. All this meriting junk is not something I'm comfortable with. And now it's clear to me that I don't have to be. I can just be me. My writing is me, my blog is me, my promotion and meriting has to be me too. If I weren't falling asleep at the keyboard right now, I'd be dancing. Over and out.

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: