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.