Using SkinId dynamically

ajax , asp.net , javascript Chicoutimi-Jonquière, Canada
  • 9 years ago

    hi all,

    How can I change the SkinId of my Button dynamically.

    - I have 3 buttons with SkinId as "InitialSkin".

    - On click of any of the button, the SkinId of the clicked button should change to "SelectedSkin"

    But I am unable to do that. it gives me the following error:

    " The 'SkinId' property can only be set in or before the Page_PreInit event for static controls. For dynamic controls, set the property before adding it to the Controls collection."

    Any idea how can i do it?

    Regards,

    Royal

  • 9 years ago

    Hi,

    Like the error says, you have to do it in the page_preinit event.

    So, you can either cause a full postback and change the style there, but it does cause annoying flicker while the form reloads.  You could use an UpdatePanel from the AJAX library and force a partial postback with the controls being in there.

    Otherwise, you will need to amend the style of the object using javascript when the event happens.

    Regards

    Simon C

  • 9 years ago

    hi Simon,

    I was able to decode what the error mean. But whatever I have read about page_preint, it is fired whenever there is a postback event generated, so it was not going to solve my purpose. And I haven't tried AJAX as yet. As I had only one page where I need to set the style(which I thought of doing with CSS) so I did it in code behind. My purpose is solved.

    Thanks Simon for your reply.

    Regards,

    Royal

     

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“An expert is a man who has made all the mistakes that can be made in a very narrow field” - Niels Bohr