Why I should check for ThemesSelectorID.Length before setting it
My question related to chapter 2 site design:
In the ThemeSelector control code behind:
protected void Page_Load(object sender, EventArgs e)
{
if (Globals.ThemesSelectorID.Length == 0)
Globals.ThemesSelectorID = ddlThemes.UniqueID;
ddlThemes.DataSource = Helpers.GetThemes();
ddlThemes.DataBind();
ddlThemes.SelectedValue = this.Page.Theme;
}
Why I should check if (Globals.ThemesSelectorID.Length == 0)?
Why not set the value directly?
protected void Page_Load(object sender, EventArgs e)
{
Globals.ThemesSelectorID = ddlThemes.UniqueID;
ddlThemes.DataSource = Helpers.GetThemes();
ddlThemes.DataBind();
ddlThemes.SelectedValue = this.Page.Theme;
}
|