Change a label backcolor using client-side javascripting

I'm working on a small project where I need to either change the backcolor of a label or change the image on the page. The user will have a list of colors in a dropdown to pick from. I've tried many variations of the code below and nothing seems to have any effect on the label backcolor.

Here's what I have:

<script type="text/javascript">

function Color(elem)

{

var indx = elem.selectedIndex;

var lbl = document.getElementById('<%= label1.ClientID %>');

if(indx == null) alert('d_Color not found!');

else {

if(indx == 1)

lbl.backColor = 'yellow';

}

}

</script>

Any ideas???


I know I've been spending too much time coding when I start dreaming about it...
0
cassiopia
12/11/2007 6:41:39 AM
asp.net.client-side 24353 articles. 1 followers. Follow

1 Replies
546 Views

Similar Articles

[PageSpeed] 17

I figured out that lbl.style.background works for what I'm doing. Does anyone know how I can do this another way, like replacing image1 with image2?

 

Thanks :-)


I know I've been spending too much time coding when I start dreaming about it...
0
cassiopia
12/11/2007 8:08:52 AM
Reply:

Similar Artilces:

How to write data to a file in client side using javascript or someother client side scripting language.
Hi, I would like to know how to write a data to a client side file using javascript or someother client side scripting language. The file type expected is ini file. txt file would also be appreciable. Thanks in advance.   If the site is a trusted and you are running IE then you could try http://www.w3schools.com/asp/asp_ref_filesystem.asp The Old Sewing FactoryThat twitter nonsense. You can write to the server, but not to the client's machine.  Being able to do so would be a huge security breach.When you ask a question, remember to click "mark as answered"...

How to use client-side script(javascript) in DNA using .Net Remoting
Hi all,     It was known that SAO and Singleton object about .Net Remoting. When I Create an object in server side and hosting in IIS's virtual directory,I want to use javascript asynchronous invoking the remote object by HTTP channel, 80 port and SOAP formatter just like XMLHTTP invoking web service. My code as following, <script> objXmlDoc = new ActiveXObject("Msxml2.DOMDocument"); objHttp = new ActiveXObject("Msxml2.XMLHTTP"); strEnvelope = ?? objHttp.onreadystatechange = function() { ...... }   szUrl = "http://ServerNa...

When to use client side varidation and server side varidation in .net?
In .net or classic web application we can varidate user data either on client isde or server side. How to select which side varidate to be used? Thanks! Generally, I use both client and server validation. I make sure the input is in the correct format and reasonably valid on the client, then I verify the data on the server. The extent of validation also depends on the type of data that I need to validate.Here are a few references:Validating ASP.NET Server ControlsIntroduction to Validating User Input in Web FormsClient-Side Validation for ASP.NET Server ControlsSecurity Checklist...

GridView with Labels updated by JavaScript (client side) and PageMethod (server side)
I have a gridview and I'm computing a column with javascript.Example.Column 3 = Column 1 + Column 2; Therefore all three columns are templated items. It's working like a charm.. HOWEVER - and this is not good at all - upon reading the values to pass them to a webservice it of course doesn't take the client side updates values.I'm using JavaScript because otherwise I wouldnt be able to use the onKeyUp event. And I want desperatly want the onKeyUp to offer realtime updates for the calculated values rather dann forcing the user to push a "recalculate button".So.. I bas...

How to use client-side script(javascript) in .Net Remoting
Hi all,     It was known that SAO and Singleton object about .Net Remoting. When I Create an object in server side and hosting in IIS's virtual directory,I want to use javascript asynchronous invoking the remote object by HTTP channel, 80 port and SOAP formatter just like XMLHTTP invoking web service. My code as following, <script>  objXmlDoc = new ActiveXObject("Msxml2.DOMDocument"); objHttp = new ActiveXObject("Msxml2.XMLHTTP"); strEnvelope = ?? objHttp.onreadystatechange = function() { ......  }    szUrl = &...

how do i get selectedValue of drop down list server side if i am populating it using client side javascript?
 Hi All.I am populating a drop down list client side using: The drop down list is populated based on a selection of another drop down list. ddlList.options[i] = new Option(1,2); as an exampleThe populating is done as i need it to. However, a button click event i am trying to get the selectedValue of the ddlList. However, it doesn't give me it. It only gives me the selectedValue of the drop down list on first rendering. Any ideas on how i can get it?   Could You paste some code? That would be helpful. Thanks S@ss (Shashi Shekhar Singh)My BlogPlease mark a post as ANSWER ...

when to use client side / server side?
Hey, Please can someone tell me when do i need to use a client-side or a server-side? For instance, I have a dropdownlist and when the user choses one of the listitems then click on the button to submit changes,i need first to validate the new value chosen by the user by comparing it with the old value and then redirect the user to the next page if there are no errors or view an error on the other hand! so in this case what's more preferable to use a JScript (client side) or on the click event of the button pressed (server side)! waiting the reply................. thanx in adva...

In datawindow.net,access the database from client side event using javascript
In powerbuilder,for example,a datawindow has two columns:itemno,description. input an itemno,validate it.if not found from the database,return 1 to trigger itemerror event; if found,get the description of the item from the database,and fill it into the column "description". The question is how to fulfill the function in web datawindow,through web service? if so,I need an example to realize it. You will need to use AJAX or make a round trip on item change event. -- Dean Jones CEO PowerObjects http://www.powerobjects.com (612) 339-3355 Ext. 112 TeamSybase * *...

Can you change a linkbutton's text using client side javascript?
I have a linkbutton which opens a new window. When the user closes the new window, I want to change the text of the original linkbutton. The issue isn't the popup window since know how to use window.opener. The problem is that I don't know how to use javascript to change the inner text of the linkbutton which I know is rendered as anchor tags. Any suggestions? Hi, on the Page where the LinkButton is, you can output the client-side ID of the LinkButton with it's ClientID property assuming you have <asp:LinkButton ID="LinkButton1" runat="server" Text="Hello" />So you could ou...

Client Side Javascript and Dynamic Client Ids
I have a gridview that has an edit row.  When I click on edit... It pops up a inline window with modal functionality in the css... I want to fire off a webservice to bring back data to populate the input fields on the form I created... one catch I created a tab container with panels to separate out the keyed in information... So, I found that the .net is doing this to the inputs...  <input name="ctl00$cphMainBody$tcEmployeeDetails$TabPanel1$txtFirstName" type="text" maxlength="25" id="ctl00_cphMainBody_tcEmployeeDetails_TabPanel1_txtFirstNa...

server side variables in client side javascript
I want to use an ASP.net variable in client side javascript.In regular asp I used hidden fields.what is the best way to do this in ASP.NET ?thx,Intersee my blog at www.Interdevelopments.com and check the future of open mobile widget solutions at www.glowe.org By and large, I personally still use Hidden fields to store information, that either my Javascript function or my code-behind use.  I barely use the RegisterScriptBlock method(s) and that is only for situations where I want to be really dynamic with the client side functionality.  95% of the time, I can still use a...

List of client side function of extenders and controls for client side
Hello All,I am using AJAX control toolkit for my current project. Now I need to find out what client side functions I can call on an extender. Lets say I am using a PopControlExtender. Now I want to show the popup from a JS funtions.If I can do a guess then it would be something like this$find('ppce').show();From where I can find what client side functions I can call on those extensders. This is really a frusterating thing. I learn about extenders only from Learn tutorials, no help here and there. Can anybody please tell me where are documentations about all the extenders in the tool...

Changing Server-Side Control Properties by Client-Side
Hi, I have 4 server side button control. These are for choices of a competition website(A,B,C,D) and I have 1 client side button control named "Changer" on the same page. When I click the Changer I want it to disable A, if it is disabled I want it to disable B... The main question in this topic is "How can I change properties of a server-side control by client-side" My javascript side is not very well. How can I do this? Please help me. I got it guys. Thank You very much.. Hi, Here is the javascript for enable and disable two server side buttons with id Button1 and Butt...

Call a Sever side method from Client Side Javascript.
Hi Friends,  Can you tell me how can i call a Server Side method of mine from Javascript?   function StoreURL() { document.getElementbyId(METHODNAME); } Is this the correct method? Any suggestions would be appreicated. Thanks Menon  hi!document.getElementById allow you to access elements from html page  DOM in client side.to call server method from client you have to use  AJAX see this example and read this tutorial.hope it helpsorzeh code less, think more! Or do a PostBack: /////////////////////////////////// Client-side code/////////////////////////...

Web resources about - Change a label backcolor using client-side javascripting - asp.net.client-side

Oolite (video game) - Wikipedia, the free encyclopedia
Oolite is a free and open source 3D Space trading and combat simulator in the spirit of Elite . It is, as the name suggests, Object Oriented ...

Services provided by M R K Development
We jumped for joy when we first found Business Catalyst. It was a great system that seemed to dot all the I's and cross the all T's and remains ...

The Rested Dog Inn's Rainbow Bridge
Our Rainbow Bridge Page is dedicated to those Rotties that have touched our lives and crossed the Rainbow Bridge.

ppk on JavaScript (Book review)
... JavaScript. If you haven’t heard of or visited Peter-Paul Koch’s site QuirksMode , you probably haven’t been doing a whole lot of JavaScripting. ...

Sponsor: WatchMeCode
Master the art of JavaScript with this week's sponsor, WatchMeCode{:rel='nofollow'}. Read on for a special BrettTerpstra.com discount code!

CIL2010: Developing & Designing for Mobile
Speaker - Jeff Wisniewski, Web Services Librarian, University of Pittsburgh Notes from this session ... mobile will surpass desktop web access ...

Services - EngNet
EngNet is an Engineering Directory, Buyers Guide and Search Engine - Designed by Engineers to benefit the Engineering Industry. EngNet enables ...

F1SA JavaScript Enabling
Motorsport: News channel, the latest, hottest F1 and motorsport news, Formula 1, Formula 2, Formula 3, MotoGP, GP2, IndyCar, A1GP, WTCC, BTCC, ...

When in Chrome
The Motley Fool - Google launches a new Web browser.

JP Keisala's personal blog.
About Contact Instagram Life stream Just updated to WordPress 2.7 by jp on December 13, 2008 So far so good, new admin looks really good. Check ...

Resources last updated: 1/6/2016 1:21:58 PM