Code in script blocks

R

Roshawn Dawson

Hi,

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

Thanks,
Roshawn
 
B

Brock Allen

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.
 

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

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top