ASP.NET interview question:-What is the difference between render and prender event ?

 Posted by articlesmaint on 2/24/2011 | Category: .NET Framework Interview questions | Views: 17654

This is again a very nice .NET interview question and  the question can be confusing because of the common word "render". Now ASP.NET page has 4 important events. Init , Load , validate , event and render (Remember SILVER).

Now the final render is a actually a two step process.

1- First the ASP.NET UI objects are saved in to view state.
2- loaded viewstate is assembled to create the final HTML.

The first step is pre-render event and the second step is the render event.


This is the event in which the objects will be saved to viewstate.This makes the PreRender event the right place for changing properties of controls or changing Control  structure.Once the PreRender phase  is done those changes to objects are locked in and the viewstate can not be changed. The PreRender step can be overridden using OnPreRender event.


Render event assembles the HTML so that it can be sent to the browser.In Render event developers can write custom HTML  and override any HTML which is created till now.The Render method takes an HtmlTextWriter object as a parameter and uses that to output HTML to be streamed to the browser. Changes can still be made at this point, but they are reflected to the client only i.e. the end browser.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response