PC Review


Reply
Thread Tools Rating: Thread Rating: 7 votes, 3.86 average.

OnLoad (dropdownlist) is executed before OnClick (Button)

 
 
Veerle
Guest
Posts: n/a
 
      10th Mar 2004
Hi,

I have an aspx page with a dropdownlist and a button:
<form id="Form1" method="post" runat="server">
<div>
<asp:label id="Label1" runat="server">Startdate: </asp:label>
<asp:dropdownlist id="DateList" runat="server"
OnLoad="LoadDates"></asp:dropdownlist>
</div>
<div>
<asp:Button id="BtnBewaren" runat="server" Text="Bewaren"
OnClick="SaveForm"></asp:Button>
</div>
</form>

Every time the page is loaded, I fill the dropdownlist with items in
the method LoadDates. When the button is clicked, then the method
SaveForm is executed which saves the value of the currently selected
item in the dropdownlist in a cookie.

What I would like to do, is adjust the LoadDates method, so that at
the end of it, the selected item is set to the value of the cookie.
But appearantly, the LoadDates method is always executed before the
SaveForm method. So when I change the selected item at the end of the
LoadDates method, then the selected item is set to the previous value,
not the new one.

Is there a way to make sure that the SaveForm method is executed
before the LoadDates method? Or is there a way to check in the
LoadDates method, that the page was loaded without clicking the
button?
 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      10th Mar 2004
I believe the following link will help you with your sequence issue:

http://msdn.microsoft.com/library/de...nLifecycle.asp

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Veerle" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I have an aspx page with a dropdownlist and a button:
> <form id="Form1" method="post" runat="server">
> <div>
> <asp:label id="Label1" runat="server">Startdate: </asp:label>
> <asp:dropdownlist id="DateList" runat="server"
> OnLoad="LoadDates"></asp:dropdownlist>
> </div>
> <div>
> <asp:Button id="BtnBewaren" runat="server" Text="Bewaren"
> OnClick="SaveForm"></asp:Button>
> </div>
> </form>
>
> Every time the page is loaded, I fill the dropdownlist with items in
> the method LoadDates. When the button is clicked, then the method
> SaveForm is executed which saves the value of the currently selected
> item in the dropdownlist in a cookie.
>
> What I would like to do, is adjust the LoadDates method, so that at
> the end of it, the selected item is set to the value of the cookie.
> But appearantly, the LoadDates method is always executed before the
> SaveForm method. So when I change the selected item at the end of the
> LoadDates method, then the selected item is set to the previous value,
> not the new one.
>
> Is there a way to make sure that the SaveForm method is executed
> before the LoadDates method? Or is there a way to check in the
> LoadDates method, that the page was loaded without clicking the
> button?



 
Reply With Quote
 
 
 
 
Veerle
Guest
Posts: n/a
 
      11th Mar 2004
Thanks for your help.
Indeed, if a do the selection of the correct dropdownlist item in the
OnPrerender instead of in the onLoad, then the sequence is correct.

"Kevin Spencer" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> I believe the following link will help you with your sequence issue:
>
> http://msdn.microsoft.com/library/de...nLifecycle.asp
>
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get onload to occur first before Page_Load =?Utf-8?B?T3Bh?= Microsoft ASP .NET 2 13th Jun 2006 09:21 PM
base.OnLoad called, OnLoad not executed Fabio R. Microsoft ASP .NET 0 25th Mar 2005 02:21 PM
any event before OnLoad? Daves Microsoft ASP .NET 6 21st Mar 2005 04:31 PM
2.0 Masterpage events before OnLoad? Daves Microsoft ASP .NET 3 20th Mar 2005 03:08 AM
Are event callback delegates executed executed in a separate thread???? Bob Rock Microsoft C# .NET 4 15th Jul 2004 11:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:24 AM.