Web Tutorials

Interview Q & A

Code Examples

Utility Tools

ASP.NET PreInit Event and Set Page Theme

ASP.NET PreInit event is useful to set page theme before page initialised in asp.net page life cycle. This event can be used to set page theme.

Syntax

protected void Page_PreInit(object sender, EventArgs e)
{
	//Code will come here.  
}

ASP.NET PreInit Event and Set Page Theme Example - Default.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_PreInit(object sender, EventArgs e) 
	  { 
	   string themeName = (string)Session["themeName"]; 
	   if (themeName != null) 
	     this.Page.Theme = themeName; 
	   else 
	     this.Page.Theme = "Cool"; 
	  }
}

RequiredFieldValidator

RegularExpressionValidator

RangValidator

CompareValidator

CustomValidator

ValidationSummary