How to change Label text from JavaScript in example - label javascript change text
we can change the label control's text programmatically by setting up it's text property. it is very easy and simple. but if we want to change the label server control's text using javascript and on click event, then how can we do this. in this example i show how we can change the label control text using javascript. here we uses label control's attributes property and adding here a label onclick event. this event change the label's inner text.

<%@ Page Language="C#" AutoEventWireup="true"%>  
<!DOCTYPE html>
<script runat="server">
    void Page_Load(object sender, EventArgs e)
        Label1.Attributes.Add("OnClick", "javascript:document.getElementById('Label1').innerHTML = 'text updated.';");
<html xmlns="">      
<head id="Head1" runat="server">      
    <title> example - label javascript change text</title>
    <form id="form1" runat="server">      
        <h2 style="color:MidnightBlue; font-style:italic;">      
   example - label javascript change text
        <hr width="550" align="left" color="Gainsboro" />      
            Text="click here to change label text."
More examples