473,728 Members | 2,045 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

why some controls must set autopostback property to be true??

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 list, and
they all need to set autopostback property to be true, in order to make the
event of the control fires.

I know this is the must, but I dont know why. Please advise!

Thanks!

Nov 18 '05 #1
8 9363
It is that way because more often then not you want to do
other things on the form prior to taking a trip to the
server and back. Said another way, more often then not
the requirement is not to do something immediately when
the user clicks on the checkbox.

More trips to the server the "poorer" your performance is.
-----Original Message-----
why need to set autopostback property to be true?? I know autopostback eventmeans to send the form to the server automatically.

I tried checkbox, checkbox list, radio button, and radio button list, andthey all need to set autopostback property to be true, in order to make theevent of the control fires.

I know this is the must, but I dont know why. Please advise!
Thanks!

.

Nov 18 '05 #2
Because by default they are not such form controls or HTML elements that
would post to the server. Only buttons are such by default. In HTML (if you
check the HTML that results from using these controls) these controls are
such HTML elements that won't cause posting to happen. So by using
AutoPostBack you tell the control, that it should itself cause a postback
when certain action occurs (checking a checkbox, changing a selection and so
on) and as a result this creates proper javascript events and functions to
be used so that postback happens.

To cause an event to happen on the server, you don't necessarily have to
have AutoPostBack=tr ue for that specific control as long as there is some
other control that causes a postback. DIfference here is that when you have
AutoPostBack=tr ue, the control can cause the postback itself without any
extra control (to cause the postback). If control does not have
AutoPostBack="t rue", it is dependant on other controls, to cause the
postback so that events are raised (on the server).

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"Matthew Louden" <ma*******@hotm ail.com> wrote in message
news:uw******** ******@TK2MSFTN GP09.phx.gbl...
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 list, and
they all need to set autopostback property to be true, in order to make the event of the control fires.

I know this is the must, but I dont know why. Please advise!

Thanks!


Nov 18 '05 #3
Just as an interesting side-point:

If autopostback is false, and a postback is caused by another control
(say a button), events will be generated both for the checkbox and the
button, yes?

But in most code design this will lead to *two* databindings, since
the normal assumption is that only one event in generated per
postback.

Is there any way to tell which is the *last* control event to be
fired? and do the databind there?

It's almost as if we need a new event handler: AfterOtherEvent s()

;)

John

"Teemu Keiski" <jo****@aspalli ance.com> wrote in message news:<Ob******* *******@TK2MSFT NGP11.phx.gbl>. ..
Because by default they are not such form controls or HTML elements that
would post to the server. Only buttons are such by default. In HTML (if you
check the HTML that results from using these controls) these controls are
such HTML elements that won't cause posting to happen. So by using
AutoPostBack you tell the control, that it should itself cause a postback
when certain action occurs (checking a checkbox, changing a selection and so
on) and as a result this creates proper javascript events and functions to
be used so that postback happens.

To cause an event to happen on the server, you don't necessarily have to
have AutoPostBack=tr ue for that specific control as long as there is some
other control that causes a postback. DIfference here is that when you have
AutoPostBack=tr ue, the control can cause the postback itself without any
extra control (to cause the postback). If control does not have
AutoPostBack="t rue", it is dependant on other controls, to cause the
postback so that events are raised (on the server).

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"Matthew Louden" <ma*******@hotm ail.com> wrote in message
news:uw******** ******@TK2MSFTN GP09.phx.gbl...
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 list, and
they all need to set autopostback property to be true, in order to make

the
event of the control fires.

I know this is the must, but I dont know why. Please advise!

Thanks!


Nov 18 '05 #4
"John Sparrow" <js******@eccle scollege.ac.uk> wrote in message
news:13******** *************** ***@posting.goo gle.com...
Just as an interesting side-point:

If autopostback is false, and a postback is caused by another control
(say a button), events will be generated both for the checkbox and the
button, yes?

But in most code design this will lead to *two* databindings, since
the normal assumption is that only one event in generated per
postback.
That's a very false assumption. There will be one event per control which
wishes to raise an event.
Is there any way to tell which is the *last* control event to be
fired? and do the databind there?

It's almost as if we need a new event handler: AfterOtherEvent s()


I agree that we need an event for AfterPostBackEv entsButBeforePr eRender.
--
John Saunders
John.Saunders at SurfControl.com
Nov 18 '05 #5
As John explained, one event per control is are raised, and only one of them
is the event caused by a postback. In other words, only one control at a
time can cause a postback.

For example when you have page which has a CheckBox (AutoPostBack=F alse) and
a Button. In CheckBox's CheckedChanged event's handler is written
Response.Write( "CheckBox_Check edChanged") and in Button's Click
Response.Write( "Button_Cli ck")

1. You first check the checkbox
2. Cause as postback by clicking the button.
3. Output on the page is "CheckBox_Check edChanged Button_Click"

If you don't (un)check the CheckBox and just click the Button, only
"Button_Cli ck" is outputted. It means CheckChanged event is raised as state
of CheckBox changed, but Button's CLick event is raised because Button
caused the postback.

If you change it so that CheckBox has also AutoPostBAck="t rue", you always
get either "CheckBox_Check edChanged" or "Button_Cli ck" outputted, but not
both at the same time, because "touching" either of these controls causes a
postback and the event to be raised.

Hope this helped.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist


"John Sparrow" <js******@eccle scollege.ac.uk> wrote in message
news:13******** *************** ***@posting.goo gle.com...
Just as an interesting side-point:

If autopostback is false, and a postback is caused by another control
(say a button), events will be generated both for the checkbox and the
button, yes?

But in most code design this will lead to *two* databindings, since
the normal assumption is that only one event in generated per
postback.

Is there any way to tell which is the *last* control event to be
fired? and do the databind there?

It's almost as if we need a new event handler: AfterOtherEvent s()

;)

John

"Teemu Keiski" <jo****@aspalli ance.com> wrote in message

news:<Ob******* *******@TK2MSFT NGP11.phx.gbl>. ..
Because by default they are not such form controls or HTML elements that
would post to the server. Only buttons are such by default. In HTML (if you check the HTML that results from using these controls) these controls are such HTML elements that won't cause posting to happen. So by using
AutoPostBack you tell the control, that it should itself cause a postback when certain action occurs (checking a checkbox, changing a selection and so on) and as a result this creates proper javascript events and functions to be used so that postback happens.

To cause an event to happen on the server, you don't necessarily have to
have AutoPostBack=tr ue for that specific control as long as there is some other control that causes a postback. DIfference here is that when you have AutoPostBack=tr ue, the control can cause the postback itself without any
extra control (to cause the postback). If control does not have
AutoPostBack="t rue", it is dependant on other controls, to cause the
postback so that events are raised (on the server).

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"Matthew Louden" <ma*******@hotm ail.com> wrote in message
news:uw******** ******@TK2MSFTN GP09.phx.gbl...
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 list, and they all need to set autopostback property to be true, in order to
make the
event of the control fires.

I know this is the must, but I dont know why. Please advise!

Thanks!


Nov 18 '05 #6
We will have such event, it is called LoadComplete. ;-)

New lifecycle is (not all are events or phases but shows what's happening)

-Page.DetermineP ostBackMode
-Page.PreInit
-Page.ApplyContr olTheme
-Page.ApplyPerso nalization
-Page.Init/Control.Init
-Control.TrackVi ewState
-Page.InitComple te
-Control.LoadCon trolState
-Control.LoadVie wState
-Page.ProcessPos tData (Control.LoadPo stData)
-Page.PreLoad
-Load
-Page.ProcessPos tData (Control.LoadPo stData) 2nd try
-RaiseCallBackEv ent
-RaiseChangedEve nts
-RaisePostBackEv ent
-Page.LoadComple te
-PreRender
-Page.PreRenderC omplete
-Page.SavePerson alizationData
-Control.SaveCon trolState
-Control.SaveVie wState
-Render
-Unload
-Dispose

I haven't marked which happen on postback but I guess it is clear from the
context.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist


"John Saunders" <john.saunder s at SurfControl.com > wrote in message
news:uR******** ******@tk2msftn gp13.phx.gbl...
"John Sparrow" <js******@eccle scollege.ac.uk> wrote in message
news:13******** *************** ***@posting.goo gle.com...
Just as an interesting side-point:

If autopostback is false, and a postback is caused by another control
(say a button), events will be generated both for the checkbox and the
button, yes?

But in most code design this will lead to *two* databindings, since
the normal assumption is that only one event in generated per
postback.


That's a very false assumption. There will be one event per control which
wishes to raise an event.
Is there any way to tell which is the *last* control event to be
fired? and do the databind there?

It's almost as if we need a new event handler: AfterOtherEvent s()


I agree that we need an event for AfterPostBackEv entsButBeforePr eRender.
--
John Saunders
John.Saunders at SurfControl.com

Nov 18 '05 #7
"John Saunders" <john.saunder s at SurfControl.com > wrote in message news:<uR******* *******@tk2msft ngp13.phx.gbl>. ..
But in most code design this will lead to *two* databindings, since
the normal assumption is that only one event in generated per
postback.


That's a very false assumption. There will be one event per control which
wishes to raise an event.


But I said "The assumption is that only one event is generated per
postback", ie in that situation two would be generated per postback
(for different controls), not two events per control.

I wonder if there are problems with databinding in the form's
PreRender()??

John
Nov 18 '05 #8
"Teemu Keiski" <jo****@aspalli ance.com> wrote in message
news:%2******** *******@TK2MSFT NGP10.phx.gbl.. .
We will have such event, it is called LoadComplete. ;-)

New lifecycle is (not all are events or phases but shows what's happening)


....

Thank you very much for the info. You've made me a happy man!
--
John Saunders
John.Saunders at SurfControl.com
Nov 18 '05 #9

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

Similar topics

1
353
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 list, and they all need to set autopostback property to be true, in order to make the event of the control fires. I know this is the must, but I dont know why. Please advise! Thanks!
22
2182
by: Mr Newbie | last post by:
I was thinking about developing a workflow application yesterday and was musing over the different approaches than one could take in restricting specific actions on a ticket( Form ) at any said stage. One approach I have used on other systems is to prevent the action buttons appearing. For example, if one did not have the Role of Administrator, one would be prevented from deleting a ticket not created by oneself. However, it did occur...
3
2067
by: Adrian Parker | last post by:
v1.1 and v2.0 We have a problem with viewstate not being stored. What's happening is that we create controls in CreateChildControls and add them to a container on the page (whether it be a panel or a table etc). We only set the data values for the controls if not page.ispostback. But, if either of the textboxes change, the page posts back and the changed event fires twice. Protected Overrides Sub CreateChildControls() Dim...
4
304
by: rn5a | last post by:
Assume that a ASPX page uses a user control named Address.ascx which has 2 TextBoxes. This ASCX page creates 2 properties named 'Address' & 'City' using the Get & Set statements: <script runat="server"> Public Property Address() As String Get Address = txtAddress.Text End Get Set(ByVal value As String)
2
5288
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 displays a single TextBox. There's also a CheckBox in this ASPX page within the <formtags. Note that the CheckBox IS NOT a part of the user control. It has been explicitly added to the Form existing in the ASPX page. The AutoPostBack property of...
1
1503
by: teddysnips | last post by:
Visual Studio 2005 I have a moderately complicated form. It has four User Controls, which are (somewhat simplified): 1. A tree control showing an employee hierarchy Below a tab strip with three tabs: 1. A User Control containing a check box (AutoPostback = True), a
1
2101
by: danyeungw | last post by:
I get the following from the link http://support.microsoft.com/kb/314206. I need to have both work - the page stays where it is and set focus to next control. Does anyone have solution? I have been working on this for days. I am using ASP.NET 2003. Thanks. DanYeung PRB: Controls Lose Focus When You Enable SmartNavigation and AutoPostBack View products that this article applies to. Article ID : 314206 Last Review : February 23,...
1
4658
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by pressing Remove button the selecetd row will be removed. I used viewstate to keep my value for postback, I want by changing selectedvalue of...
0
3500
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by...
0
9424
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9198
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9135
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6718
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6013
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4793
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3236
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2161
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.