Code in script blocks

  • Thread starter Thread starter Roshawn Dawson
  • Start date Start date
R

Roshawn Dawson

Hi,

Does code contained in <% %> blocks cause postbacks to the server?

Thanks,
Roshawn
 
Code in <%%> blocks get executed during the rendering of the page. Render
happens late in the life cycle of the page on the server -- after Page_Init,
Page_Load, Validate, server events (such as change and click) and Page_PreRender.

Code in <script runat=server> blocks is code added to the class generated
by ASP.NET for your ASPX file. You put methods, and event handlers typically
in this code block.

What causes postbacks are typically controls you declare in the <form runat=server>
such as a <asp:Button>. ASP.NET's programming model is an event based architecture,
so when there is the postback you handle the postback by handling Button's
Click event. If you have other controls on the form that might have caused
the postback (instead of the button) you'd hande their events.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top