Yes, your Page_load will always be called before the eventhandler that
raised the postback. This is normal behaviour.

What is the problem in shifting the code that needs to be run into the
button_Click eventhandler itself ?

On Mar 4, 9:29 pm, Seguros Catatumbo <[email protected]>
wrote:
> Hey, i am using asp.net 3.5's calendar control, which always posts
> back. I want to execute some code when a post back has been done, but
> only when a button has been clicked.
>
> In the Page_Load function i tried to do this:
>
> if (Page.IsPostBack && has_clicked==true)
> {
>    ...
>
> }
>
> protected void button_Click(object sender, EventArgs e)
>     {
>         has_clicked = true;
>     }
>
> The problem is that the page_load runs before button_Click when
> clicking the button, so has_clicked is always false.
>
> All of this could have been fixed if asp's calendar control would have
> an autopostback property so i could disable it. I guess i must move
> the code out of the Page_Load function but don't know how would i
> execute it.
>
> Thanks in advance

Reply via email to