Thursday, March 29, 2012

Sequence of code processing

I am fairly new to ASP.Net and am using VS2005 and .Net 2.0 for page
creation. I am using VB as a language and have VB code between script tags
at the top of my page. I also have a button on my page that runs a
Protected Sub that performs some processing when clicked as noted below:
Protected Sub BtnNewSubfile_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles BtnNewSubfile.Click
...
End Sub
Does this code run before the code at the top of the page or after. Or does
the code at the top of the page run at all when I click the button? Thanks.
DavidDavid,
ASP.Net doesn't run in a linear fashion as classic ASP did. It's
completely event-driven. That means your button click event will be fired at
a particular time based on the design of ASP.Net, not based upon the
location of the code. Paul Wilson has a great article listing all the
various events that will occur on a page and the order in which they occur
at: http://blogs.crsw.com/mark/articles/471.aspx
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199...2006
"David" <dlchase@.lifetimeinc.com> wrote in message
news:%236lzifv8GHA.4996@.TK2MSFTNGP03.phx.gbl...
>I am fairly new to ASP.Net and am using VS2005 and .Net 2.0 for page
>creation. I am using VB as a language and have VB code between script tags
>at the top of my page. I also have a button on my page that runs a
>Protected Sub that performs some processing when clicked as noted below:
> Protected Sub BtnNewSubfile_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles BtnNewSubfile.Click
> ...
> End Sub
>
> Does this code run before the code at the top of the page or after. Or
> does the code at the top of the page run at all when I click the button?
> Thanks.
> David
>
Thank you Mark. I'll check it out.
David
"Mark Fitzpatrick" <markfitz@.fitzme.com> wrote in message
news:%23MkA$hx8GHA.4572@.TK2MSFTNGP02.phx.gbl...
> David,
> ASP.Net doesn't run in a linear fashion as classic ASP did. It's
> completely event-driven. That means your button click event will be fired
> at a particular time based on the design of ASP.Net, not based upon the
> location of the code. Paul Wilson has a great article listing all the
> various events that will occur on a page and the order in which they occur
> at: http://blogs.crsw.com/mark/articles/471.aspx
> --
> Hope this helps,
> Mark Fitzpatrick
> Former Microsoft FrontPage MVP 199...2006
> "David" <dlchase@.lifetimeinc.com> wrote in message
> news:%236lzifv8GHA.4996@.TK2MSFTNGP03.phx.gbl...
>

0 comments:

Post a Comment