Solved

ASP.NET Postback process

Posted on 2014-11-12
6
101 Views
Last Modified: 2014-11-15
What controls can cause a PostBack for an ASP.NET Page? And do these control(s) have the AutoPostback property?
What events associated with a control can cause a PostBack?
0
Comment
Question by:metro156
  • 3
  • 3
6 Comments
 
LVL 17

Expert Comment

by:OriNetworks
ID: 40437946
Just about any control that the user can interact with will usually cause a postback if an event is wired to that control including invisible controls and custom controls. It is also possible to initiate a postback with javascript on behalf of a control. Not all controls support the AutoPostback property. You can view a list of .net WebControls at http://msdn.microsoft.com/en-us/library/System.Web.UI.WebControls(v=vs.110).aspxhttp://msdn.microsoft.com/en-us/library/System.Web.UI.WebControls(v=vs.110).aspx
0
 

Author Comment

by:metro156
ID: 40438019
I just noticed there is no AutoPostBack property listed when you select a button control properties.
However, I see UseSubmitBehavior property on a button control which submits no matter if the property is False or True.
So apparently all buttons cause submit. There also must be a way to prevent a button from submitting to the server and
use the client side code. (jQuery)

See article on usesubmitbehavior
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.usesubmitbehavior(v=vs.110).aspx

This article below talks about the AutoPostBack property
http://www.c-sharpcorner.com/uploadfile/2f73dd/what-is-postback-in-Asp-Net/
0
 
LVL 17

Expert Comment

by:OriNetworks
ID: 40438037
UseSubmitBehavior will still postback to the server but controls if it acts as a form submit button. to prevent a .net button from causing a postback you can use the OnClientClick property
OnClientClick="return false;"

Open in new window


Is there something specific you were trying to accomplish that still is not working?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:metro156
ID: 40438067
The OnClientClick property --- I do not see that property listed in the properties window when I select the button control.
Why is that?
0
 
LVL 17

Accepted Solution

by:
OriNetworks earned 500 total points
ID: 40438125
I'm not sure what software you are using and that is outside the scope of this question but it is listed for the Button control in visual studio.

In summary, the microsoft reference will list all webcontrols and if they support the autopostback property and any event wired to a server side control may postback to the server including simple javascript. If you are trying to prevent a button from posting back, the OnClientClick property will let you override its default behavior by using return false.
0
 

Author Comment

by:metro156
ID: 40441289
Ok I did find the OnClientClick property. So that answers that.  You have indicated if there is an event handler tied to that
control, you will be able to postback.  
However, that would require the AutoPostBack property of that control to be set to True, correct?
If you set the control's AutoPostBAck property to False, then the control would not cause a postback  even though
you tied an event handler to it, correct?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem to alignment 3 71
Configure a website to disconnect/timeout after 30 minutes 1 439
Image Orientation On Website 6 50
Video on my site 4 53
Foolproof security solutions has become one of the key necessities of every e-commerce or Internet banking website. If you too own an online shopping site then its vital for you to equip your web portal with customer security features that can allow…
Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I ha…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

939 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now