Home All Groups Group Topic Archive Search About

Dynamically changing LinkButton properties

Author
6 Jan 2006 4:02 PM
treilly via DotNetMonster.com
I currently have several LinkButton controls contained inside a placeholder
in my asp.net form.  When a user clicks on any one of these, I need to change
the clicked LinkButton's CssClass.  I am trying to do this inside of the
command event handler for the LinkButtons.  However, I cant gain access to
the LinkButton properties.  The only things I have access to are the command
arguments and the command name.  I have also tried using the Findcontrol
method to gain access to it's properties, but to no avail.  AND I have also
tried to use themes, but apparently these MUST be in place in the page pre-
init (I need to change it dynamically).  Does anyone have any ideas as to how
this can be accomplished?  Thank you for the help

TR


Author
6 Jan 2006 4:47 PM
Steve Walker
In message <59f54c1d266f1@uwe>, treilly via DotNetMonster.com
<u15154@uwe.?.invalid> writes
>I currently have several LinkButton controls contained inside a placeholder
>in my asp.net form.  When a user clicks on any one of these, I need to change
>the clicked LinkButton's CssClass.  I am trying to do this inside of the
>command event handler for the LinkButtons.  However, I cant gain access to
>the LinkButton properties.  The only things I have access to are the command
>arguments and the command name.  I have also tried using the Findcontrol
>method to gain access to it's properties, but to no avail.  AND I have also
>tried to use themes, but apparently these MUST be in place in the page pre-
>init (I need to change it dynamically).  Does anyone have any ideas as to how
>this can be accomplished?  Thank you for the help

private void LinkButton1_Command(object sender, CommandEventArgs e)
{
        LinkButton l = (LinkButton)sender;
        l.CssClass = "MyCssClass";
}

?

--
Steve Walker
Author
6 Jan 2006 6:36 PM
treilly via DotNetMonster.com
Thank you very much Steve.  I don't know why I didn't think of that myself.
I had gone about doing that a different (not to mention, stupid) way by
creating a new control using the FindControl method, and then trying to
access it through there.
Thanks again!!