Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to change a controls SkinID at runtime (asp.net 2.0)

Reply
Thread Tools

How to change a controls SkinID at runtime (asp.net 2.0)

 
 
stephen.mcallister@gmail.com
Guest
Posts: n/a
 
      09-21-2006
I am toying around with Personalization in asp.net 2.0 and would like
my users to be able to choose a SkinID at runtime.
I have a theme with a default gridview skin and a custom skin.
There are 2 buttons on a Control that I was hoping I could use to
switch the SkinID, but it appears it's not that easy to do during
runtime.

Here is the code I tried to use

protected void imgBtnDefaultColour_Click(object sender,
ImageClickEventArgs e)
{

gvReqListing.SkinID = "";

}
protected void imgBtnSecondColour_Click(object sender,
ImageClickEventArgs e)
{
gvReqListing.SkinID = "gvWebPart";

}

and the error message that I received

The 'SkinId' property cannot be changed dynamically if Page has a
stylesheet theme. For dynamic controls, set the property before calling
ApplyStyleSheetSkin().

Any help or suggestions would be greatly appreciated.

 
Reply With Quote
 
 
 
 
clintonG
Guest
Posts: n/a
 
      09-21-2006
SkinID can only be assigned in PreInit which is where we also dynamically
assign Themes.

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
MAP 43°2'17"N 88°2'37"W : 43°2'17"N 88°2'37"W

<> wrote in message
news: ps.com...
>I am toying around with Personalization in asp.net 2.0 and would like
> my users to be able to choose a SkinID at runtime.
> I have a theme with a default gridview skin and a custom skin.
> There are 2 buttons on a Control that I was hoping I could use to
> switch the SkinID, but it appears it's not that easy to do during
> runtime.
>
> Here is the code I tried to use
>
> protected void imgBtnDefaultColour_Click(object sender,
> ImageClickEventArgs e)
> {
>
> gvReqListing.SkinID = "";
>
> }
> protected void imgBtnSecondColour_Click(object sender,
> ImageClickEventArgs e)
> {
> gvReqListing.SkinID = "gvWebPart";
>
> }
>
> and the error message that I received
>
> The 'SkinId' property cannot be changed dynamically if Page has a
> stylesheet theme. For dynamic controls, set the property before calling
> ApplyStyleSheetSkin().
>
> Any help or suggestions would be greatly appreciated.
>



 
Reply With Quote
 
 
 
 
nguyenxuancanh nguyenxuancanh is offline
Junior Member
Join Date: Apr 2008
Posts: 1
 
      04-12-2008
you use session to save your setting, after that redirect site,like this:
protected void rad1_SelectedIndexChanged(object sender, EventArgs e)//rad1 is radioButtonList
{
Session["themesPage"] = rad1.SelectedValue;
Server.Transfer(Request.Path);
}

at method Page_PreInit, you use:
protected void Page_PreInit(object sender, EventArgs e)
{
string thm;
thm = (string)Session["themesPage"];
if (thm != null && thm != string.Empty)
{
Page.Theme = thm;//name theme
rad1.SelectedValue = thm;
}
else
{
Session["themesPage"] = rad1.SelectedValue;
Page.Theme = "theme1";//name theme
}


Good luck
 

Last edited by nguyenxuancanh; 04-12-2008 at 10:25 AM..
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change CSS Runtime (asp.net 2.0) pinsoftek ASP .Net 2 02-03-2009 09:12 AM
Programmatically Set SkinId Properties For Controls Within UpdatePanel? Joey ASP .Net 0 10-24-2007 08:55 PM
How could I change the NavigateUrl property at runtime based on another controls property ? Radu ASP .Net 2 01-25-2007 09:51 AM
Change the layout of controls at runtime? refresh ASP .Net 1 11-16-2006 09:23 PM
Re: how to change an image url at runtime Mark Kamoski ASP .Net 0 07-20-2003 04:44 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57