473,386 Members | 1,864 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,386 software developers and data experts.

autopostback vs submit?

How do I tell wether I'm seeing autopostback vs submit button click in
Page_load?

Thanks for any clues.

Mar 6 '06 #1
3 2415
Take a brief look at the description of the various stages of the page cycle:
http://msdn.microsoft.com/library/de...nlifecycle.asp

You would typically use the Load event to perform actions common to all
requests. Then during handling the postback events you would realize which
control made a request. Then you can use the PreRender to do what you
probably were trying to do in the Load event. In other words, in the
standard programming style in ASP.NET you do not need to decide which control
caused the postback during the page load event.

Having said so, you can still check the value of
Request.Form["__EVENTTARGET"] to find the ID of the control that caused the
AutPostBack.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:
How do I tell wether I'm seeing autopostback vs submit button click in
Page_load?

Thanks for any clues.

Mar 6 '06 #2
Hi Michael,

If the user presses the Submit button, you should process the form data in a
method that handles the Click or Command event of the button, e.g.
In C#:
void Button1_Click(Object sender, CommandEventArgs e) {
//process the form data
}

In VB:
Protected Sub Button1_Command(ByVal sender As Object, ByVal e As
CommandEventArgs) Handles Button1.Command

End Sub
If a dropdownlist on the page had its index changed then you would process
all consequent actions in a method that handles the SelectedIndexChanged, e.g.
void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
//do any processing that is dependent on
//changing the list1 selection
}

Using this approach, you can leave the page load event only for processing
actions common to all requests or to actions specific to the first request of
the page, e.g. populating the dropdownlist when the page is first requested:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//add code to populate the dropdownlists
}
}

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:

Thanks for the page cycle link. I'm still puzzled though, when a user
presses the submit button I need to process the form data. I was going to
call a function from the Page Load with ispostback = true. But if a control
has autopostback enabled (a drop down list for instance) how do I know if I
can process the data or it's just a dropdownlist refreshing.

Thanks much.

Michael
"Phillip Williams" wrote:
Take a brief look at the description of the various stages of the page cycle:
http://msdn.microsoft.com/library/de...nlifecycle.asp

You would typically use the Load event to perform actions common to all
requests. Then during handling the postback events you would realize which
control made a request. Then you can use the PreRender to do what you
probably were trying to do in the Load event. In other words, in the
standard programming style in ASP.NET you do not need to decide which control
caused the postback during the page load event.

Having said so, you can still check the value of
Request.Form["__EVENTTARGET"] to find the ID of the control that caused the
AutPostBack.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:
How do I tell wether I'm seeing autopostback vs submit button click in
Page_load?

Thanks for any clues.

Mar 6 '06 #3

Thanks for the page cycle link. I'm still puzzled though, when a user
presses the submit button I need to process the form data. I was going to
call a function from the Page Load with ispostback = true. But if a control
has autopostback enabled (a drop down list for instance) how do I know if I
can process the data or it's just a dropdownlist refreshing.

Thanks much.

Michael
"Phillip Williams" wrote:
Take a brief look at the description of the various stages of the page cycle:
http://msdn.microsoft.com/library/de...nlifecycle.asp

You would typically use the Load event to perform actions common to all
requests. Then during handling the postback events you would realize which
control made a request. Then you can use the PreRender to do what you
probably were trying to do in the Load event. In other words, in the
standard programming style in ASP.NET you do not need to decide which control
caused the postback during the page load event.

Having said so, you can still check the value of
Request.Form["__EVENTTARGET"] to find the ID of the control that caused the
AutPostBack.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:
How do I tell wether I'm seeing autopostback vs submit button click in
Page_load?

Thanks for any clues.

Mar 6 '06 #4

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;
1
by: Null | last post by:
Hello -- Is there a way to prevent the autopostback of a drop down list if there is a "default" item in the list -- example, a drop down list where the first item says "Select One" and the...
2
by: SLE | last post by:
A web user control exposes a RadioButtonList (with AutoPostBack = true) called "Question". This control also has an embedded RequiredFieldValidator control. 1. Main ASPX page is populated with...
5
by: Hans Kesting | last post by:
Hi, I have a pulldown with both AutoPostback set to true and a validator. When I select an "invalid" value from the pulldown, the validator message shows briefly, then a postback occurs and the...
7
by: Ron | last post by:
Hello all, I don't understand why my pageis not posting back to the server when I change the selection on a radio list. I have a page that both accepts new personal info. or allows editing to...
2
by: Sean Chapman | last post by:
I've got a simple page I've made with a few controls (Treeview, Dropdownlist, ..). I'm running into an issue with autopostback. If I set it to AutoPostBack = "True", when the event should fire I...
1
by: Sean Chapman | last post by:
I've got a simple page I've made with a few controls (Treeview, Dropdownlist, ..). I'm running into an issue with autopostback. If I set it to AutoPostBack = "True", when the event should fire I...
2
by: Bob Peek | last post by:
I have created a master page with a single asp:button that posts the page without page validation. On the content page, I have a variety of asp controls including text box, drop down list...
2
by: benfly08 | last post by:
Hi, guys. I have a web page that contains a drop-down list, a text box and a button. I set drop-down list and text box AutoPostBack property as false. When I run this page, I selected something...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.