Solved

ASP.NET Postback process

Posted on 2014-11-12
6
106 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
New Relic: Our company recently started researching several products to figure out what were the best ways for us to increase our web page speed and to quickly identify performance problems that we may be having. One of the products we evaluated wa…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
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…

734 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