Solved

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

Posted on 2013-12-30
4
331 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:
ItWorked earned 500 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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.…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 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