Changing the text of a asplabel using javascript

Hi:

I have a label in a ascx. and a list box.

I want to be able to change the text of the label

when the users change their listbox selection.

I can get the event handler to fire, get the value of the

selected inex  but I cant get the value of the label to change.

Please help.

thanks!

KP

0
sundarbun
5/2/2005 1:31:03 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

3 Replies
399 Views

Similar Articles

[PageSpeed] 57

Are you using the Event Handler for DropDown_SelectedIndexChanged to change the value of the label?

Please post your server side code here, which helps us to answer your question.


My ASP.NET blog ~
God doesn't play dice...
0
JamesBond
5/2/2005 3:04:44 PM
heya,

here is the poor mans' version of doing what you got in mind...

Label1.Text = myDropDownListBox.SelectedItem.Text;

0
brdrok
5/2/2005 6:04:45 PM

You want a javascript solution. I'll assume that you know how to setup javascript within the server side.

The Label is a <span> tag. It has an id attribute that matches the ClientID property of the Label. So you can use document.getElementById("[clientid to label]") to get the <span> tag object. Now you need to change its value. <span> tags show their info on the page as "innerHTML" (the info between <span> and </span>). There is an innerHTML property on the object you get.

document.getElementById("[clientid to label]").innerHTML = document.getElementById("[clientid to dropdownlist]").value;

Set this in the onchange event of the DropDownList.

For a good reference on DHTML, click here.


--- Peter Blum
Creator of Peter's Data Entry Suite (formerly Professional Validation And More and Peter's Date Package) and Peter's Polling Package
www.PeterBlum.com
0
PLBlum
5/2/2005 10:51:40 PM
Reply:

Similar Artilces:

using javascript to change .net web form properties
Hello everyone, I'm fairly new to ASP.NET and I'm trying to find the best solution to this problem I'm having.  I believe ultimately what I need to be able to do is change the ImageUrl value via javascript of an ImageButton.  A small example of what I'm working on can be found here in a javascript form:http://www.msu.edu/~sebenic3/This is a simple data input method for a survey. There are three distinct columns, when you select a number within a column it will change the .gif image to show it's selected and then populate the textbox with that value.  I...

How to change txt2.text when the txt1's.text changes using JavaScript?
Hello! I want some JavaScript (or any other client-side) solution for my problem thatdescribed here:  http://forums.asp.net/p/1382766/2930267.aspx In a few words, my problem is that i don't know the way to change the txt2.text valuewhen the txt1.text value changes... Please read the http://forums.asp.net/p/1382766/2930267.aspx first...I want only JavaScript solution... Thank you very much! Like this? <input type="text" id="TextBox1" name="TextBox1" onchange="textBox1OnChange(this);" runat="server" /><input type...

How to get a changed web form control name to use in javascript?
When you use a user control, all web form controls names get changed by .NET some like ctl0_ctl5_txtFirstName where txtFirstName is the actual name I gave. in Javascript, to refer to this control I can do like document.getElementById('ctl0_ctl5_txtFirstName') but the thing is from time to time, the prefix, in this case ctl0_ctl5_, gets changed again. So the javascript does not work anymore. Is there any way of handling this situation? Is there any server method to get the prefix? If then I can send the prefix to client side and prefix it with actuall control name like var ...

Check if the text box "text" has changed (RePost from web forms forum)
Greetings! How can i know if the "text" inside of a text box has changed? For example, I currently have this: if (txtMU.TextChanged()) { } But this does not work. The other idea I had was to assign the existing value of the text box to a string and then when the user click the save button I can create a conditional statement to compare the original string with the new string. However, I would like something more effective as I have like 12 text boxes to compare. Thanks, EduardoThanks,Please Mark this post as answered if it was helpful. Here is the easiest way that I have ...

C#.NET WEB APPLICATION
hei guys, i need help on my application, i'm using C#.NET as front-ed and SQL as back-end, aside from a datagrid, i want to display my data using textboxes and not a datagrid, i can do it using Visual Basic 6 but since i'm a newbee at C#.NET i don't know how to do it, specially the codes, can anyone help me with it? thank you in advance! If you are doing windows development, i would suggest using 'DataForm wizard' (Use Solution Explorer-->Rightclick project-->Add new Item-->New DataForm). It will guide you through steps. If you are doing web apps. Use quickstart to learn them. h...

problem in binding a text box with datagrid at run time using web forms using C#
the code below is working properly. in this code 2 times(timeIn and timeOut) are subtracted and the result is bound to a datagrid(dbgMyGrid), what i want is that now the value (difference of both times) should also bound with a textbox control.  or inspite of binnding the SQl Squery result with datagrid(dbgMyGrid) it should directly bound to a textbox. Any of the result is appraicated. this.lblEmpTimeOut.Text=DateTime.Now.ToShortTimeString();SqlConnection myConnection = new SqlConnection("server=WAHEED;uid=sa;pwd=waheed;database=HRMS_EMPLOYEE");SqlCommand myCommand = ne...

can someone one give me difference between web form and mobile web form and which or where or when i'm using the forms?
thanks Marc Hi Marc, Based on my understanding, you want to know the differences between the ASP.NET web application and ASP.NET mobile web application. If I have misunderstood you, please feel free to let me know. The ASP.NET forms are used to develop the ASP.NET pages for desktop browsers and The ASP.NET mobile forms are used to develop the ASP.NET pages for mobile device browsers. When we create the ASP.NET mobile web forms pages, we can use nearly all the features of ASP.NET. But there are a couple of compatibility issues: Error Handling and Reporting. Tracing. Using Redi...

Implementing .Net Form into an APS.net web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an ASP.net web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

Need Windows Form to Retrieve Information From Web Form
I have a cash and carry web site that customers can order products, the next day come in to the company to pay and pickup. I would like to create a windows application for the company to do two things: 1. download all the orders from the day before 2. upload price changes, product changes, category changes I've search the internet and forums and the only thing I can find that I think would actually link these two together would be a web service. Can you please tell me if I am heading in the right direction or if there is another method to link the two applications, if there are any pitf...

dynamically changing the text of a table using javascript
 Hi,im i have one table named as tblBrandsand one button.My table contains 5 rows in each row it has text as NOT SELECTEDnow, when i click on the button im creating a table dynamically in that table im fetching the cell's value from the database. every cell one corressponding cell which contains an imagebutton which displays image of plus sign. when user clicks on + sign the text from corressponding cell must replace the text of table cell. For replacing the text im calling one javascript functionwhich replaces the text of the table's cell jst for  a moment and in very seco...

VS.NET 2005 Web Forms Designer Changes
Word on the street is the web forms designer architecture has vastly improved in VS.NET 2005. That's great for me, since I write plenty control designers and add-ins and 2003 has bothered me in more ways that I care to discuss. But I can't find a good place to get the info on the designer changes in 2005. Could someone link me to some resources? Thanks There are a few resources: Check out the quickstarts for beta1. i think we added some very basic details there, but there are also some comments in 477688 686110 for some general details.SimonThis posting is provided "...

Using excel/automation from a .net web form fails, why?
Hi all - From my codebehind I'm attempting to write the contents of a DataSet to Excel. However, it appears that I cannot start Excel from my codebehind to accomplish this. Doing so causes the following error: Cannot execute a program. The command being executed was "c:\winnt\microsoft.net\framework\v1.1.4322\csc.exe" /noconfig @"C:\WINNT\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\webservice_icspos_consumer\bd8c4cb9\af1c8054\s33rwgwf.cmdline". I've referenced Microsoft Excel 10.0 Object Library which also brings in - Microsoft Office 10.0 Obje...

Using Web Form to navigate through records and save changes
I have a Web Form much like you sould see in an Access DB that has a bunch of text fields that is populated from a DB.  I would like a user to be able to view the records and press buttons like Next, Previous, First and Last to navigate.  I would also like them to be able to make changes in a field and to save the changes when clicking the "Save" button.  (I will also add this to the nav buttons if changes are made, but that is for a later time) So far, the navigation works fine as long as I re-fill the DA and re-bind my page on each Postback.  However, if I do that, the...

SQL statement using text boxes on web form
I need to add a where clause to my Select Statement that includes the date entries from two text boxes on the web form. For example; [code]Where [Date Entered] Between HistoryStartText.Text AND HistoryEndText.Text AND [Payment Type]<>'Monthly' AND [Client_ID]=" & _ ClientIDSent[/code] Thanks for any help,Thank youJackxxx I have tried using variables and it still is not working. When I use the variables the error is Exception Details: System.Data.SqlClient.SqlException: Invalid column name '1/1/2003'. So I'm getting the date but receiving the above ...

Web resources about - Changing the text of a asplabel using javascript - asp.net.web-forms

JavaScript Kit- Your comprehensive JavaScript, DHTML, CSS, and Ajax stop
Your comprehensive JavaScript, DHTML, CSS, and Ajax stop

Let's Code: Test-Driven Javascript by James Shore — Kickstarter
James Shore is raising funds for Let's Code: Test-Driven Javascript on Kickstarter! A screencast series focusing on rigorous, professional Javascript ...

Eloquent JavaScript: A Modern Introduction to Programming
... and pragmatics. I loved the tutorial-style game-like program development. This book rekindled my earliest joys of programming. Plus, JavaScript! ...

JavaScript - Wikipedia, the free encyclopedia
programming styles. JavaScript was formalized in the ECMAScript language standard and is primarily used in the form of client-side JavaScript ...

Open Directory - Computers: Programming: Languages: JavaScript: Tools: Obfuscators
... editor - report abuse/spam - help the entire directory only in Tools/Obfuscators Description Top : Computers : Programming : Languages : JavaScript ...

Facebook File-Transfer App Pipe Relaunches, Now Works Via JavaScript, WebRTC
... allowed Facebook users to send and receive files up to 1 gigabit in size. A new version of Pipe debuted Monday, and the app now works via JavaScript ...

Under the Hood: The JavaScript SDK - The use of polyfills - Facebook
Facebook Engineering hat eine Notiz mit dem Titel Under the Hood: The JavaScript SDK - The use of polyfills geschrieben. Du kannst den vollständigen ...

JavaScript
The Facebook SDK for JavaScript provides a rich set of client-side functionality for adding Social Plugins, making API calls and implementing ...

Senior Front-End Developer (Javascript and AJAX)
Company: Sometrics Category: Software Development Location: Los Angeles, CA How to Apply: jobs@sometrics.com Description: We are looking for ...

Badass JavaScript (@badass_js) on Twitter
WebGLWorker is an open source library that allows using WebGL from Web Workers. Great work as always from @kripken . blog.mozilla.org/research/2014/… ...

Resources last updated: 1/18/2016 4:39:11 AM