Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to dynamically set a VB.NET control's class?

Posted on 2013-12-30
4
Medium Priority
?
339 Views
Last Modified: 2013-12-31
I am trying to dynamically set a class (not the style attribute, the class) on a VB.NET control whenever the user selects an item from a dropdown. The dropdown has a list of class names in it, and I want to show the user what the effect of that class is by setting another control's class to that selected class. I am unable to set the CssClass of the target control because that attribute is read-only.

Is there a way to dynamically set a control's CLASS by responding to a dropdown list change?

thanks experts!
0
Comment
Question by:rascal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 15

Expert Comment

by:Ess Kay
ID: 39746656
have yo looked into reflection


stackoverflow.com/questions/983157/vb-net-iniatialising-a-class-using-system-reflection-and-system-type-to-create-a
0
 
LVL 4

Accepted Solution

by:
Hiran Desai earned 2000 total points
ID: 39747974
I don't know where you find that CssClass is readonly...as

With your question i have cross checked my knowledge with MSDN at Webcontrol.CssClass

If still in case doesn't work then you can do it by
control.Attributes.add("class","classname");

Open in new window


Let me know if this doesn't works
0
 
LVL 1

Author Comment

by:rascal
ID: 39748645
Thanks ItWorked,
When I attempted to set the CssClass property, the tooltip presented by Visual Studio displayed that it was read only, and Visual Studio underlined the statement, but I'll give it a try and also try the control.Attributes.add("class","classname") approach and let you know.
0
 
LVL 1

Author Closing Comment

by:rascal
ID: 39748688
Thanks ItWorked, the control.Attributes.add("class","classname") worked.

I also tried the CssClass version but that still didn't work. Below is the element I was trying to dynamically add the CssClass to:

<aside id="ctlSampleText" class="<%=sSelectedScheme%>" runat="server" ClientIDMode="Static">
          This is sample text. <a href="javascript:void(0)">This is a sample link</a>
      </aside>
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question