RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: .NET
Expertise: Intermediate
Aug 4, 2009

Make Minor Code Changes to .ASPX Pages Without Rebuilding

If you have a web site already in production, but need to make a small coding fix to an .aspx page, instead of making the change in the code-behind file and then rebuilding and redeploying the entire project, you can make minor changes in the .aspx page code itself, writing the code as inline code. The workaround involves using the OnPreRender event (which is often unhandled) to inject new code into the page:

<script language ="visualbasic" runat ="server">
   Protected Overrides Sub OnPreRender( _
      ByVal e As System.EventArgs)
      your code here
   End Sub

Note: This technique works only when you're not already handling the OnPreRender event in the code-behind file.

You'll find this technique very useful when you need to make small changes in production environments, because it takes effect immediately and doesn't require any application downtime.

Jaya Nehru
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date