Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

AJAX-- access BackColor  And  ForeColor properties of the TextBox

Posted on 2012-03-11
2
Medium Priority
?
287 Views
Last Modified: 2012-03-26
TextBox has BackColor  And  ForeColor properties.  It's easy to control/access these properties in Server-side code.  My question:

How can I access these properties in client-side code using AJAX or/and javascript ???

<asp:TextBox ID="txtName" runat="server"></asp:TextBox>

   <script type="text/javascript">

            var myName = document.getElementById('txtName');

            How can I access BackColor  And  ForeColor HERE???

    </script>


Thanks
0
Comment
Question by:niceguy971
2 Comments
 
LVL 14

Accepted Solution

by:
dejaanbu earned 2000 total points
ID: 37708488
like this:

 <script type="text/javascript">

            var myName = document.getElementById('txtName');

           myName.backgroundColor = '#336699';
           myName.color = '#FFFFFF';

    </script>

Open in new window


here is the Css and Js style attributes
http://www.comptechdoc.org/independent/web/cgi/javamanual/javastyle.html


if u r using master page,  u may need to use 'txtName.ClientId' instead of 'txtName'
0
 

Author Closing Comment

by:niceguy971
ID: 37769435
Thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

886 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