Monday, July 16, 2007

Personalization and Themes

Create skins and theme in your project.

1.) Right click in your project and select “Add ASP.NET Folder” and choose Theme.And then

Change name to “lookandfeel”.

2.) Right click upon it and select “Add New Item…” ,choose Skin File,change name to “Blue.skin”.

And then add next one skin file and named to “BrownTheme.skin”.

In Blue Skin file,add code like this,

< skinid="BlueTheme" runat="server" backcolor="Aqua">

In BrownTheme Skin file, add some code as bellow …

< skinid="BrownTheme" runat="server" backcolor="Brown">

I don’t expain all in there ,I will assume that you have some experience in Asp.net web application.

1. 1.) Add Login.aspx file in your project. And then add Login, HyperLink control from toolbox.

2. 2.) Add Default.aspx file.

- Change to source view and Write like this “Thank for visit my site!”.

- And then add DropDownList, Button and LoginStatus control from toolbox.

3. 3.) Add Register.aspx file.

- Add CreateUserWizard.

In Login.aspx ,

For HyperLink,Set

- NavigateUrl = "~/Register.aspx"

- Text=” Register”

For Login, Set

- DestinationPageUrl="~/MyTest/Default.aspx"

In Register.apsx ,

For CreateUserWizard , Set

- ContinueDestinationPageUrl = "~/MyTest/Login.aspx"

In Default.aspx,

For Doucment ,Set

- Theme = "lookandfeel"

For LoginStatus, Set

- LogoutPageUrl="~/MyTest/Login.aspx"

- LogoutAction="Redirect"

For DropDownList,Set

- ID="lstPageTheme"

And then add these two item

< text="Blue" value="BlueTheme">

< text="Brown" value="BrownTheme">

For Button,Set

- Text="Save"

Open your web.config and add these code at before closing the system.web tab.

< enabled="true" defaultprovider="AspNetSqlProfileProvider">

<>

< name="PageTheme">

< /properties >

< /profile >


Open your Default.aspx file and then change to code view ,and then add these event and code.

public string _SelectTheme;

public override String StyleSheetTheme

{

get

{

return _SelectTheme;

}

set

{

_SelectTheme = value;

}

}

//you can only change your skin and theme in PreInit event

protected void Page_PreInit(Object sender, EventArgs e)

{

ProfileCommon pc = (ProfileCommon)HttpContext.Current.Profile;

lstPageTheme.SkinID = pc.PageTheme;

}

//to save the theme

protected void Button1_Click(object sender, EventArgs e)

{

Profile.PageTheme = lstPageTheme.SelectedValue;

Response.Redirect(Request.Path, true);

}




No comments:

Google Ad