Click here to Skip to main content
15,889,651 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all

How to change label text when I click the button at C# Web..?
Anybody can help me ? Thank you for supporting...

The ID button name is button3
The ID label name is Label3


Regards



Amad

What I have tried:

Put
AssociatedControlID="Button3" at HTML

<asp:Label ID="Label3" runat="server" Text="Amad" AssociatedControlID="Button3"> 

But It not worked
Posted
Updated 24-Jul-18 2:02am

1 solution

Since this is the web you have to first decide if you want to change the label's text with a postback or without a postback. With a postback means you can do it in C# but it's also easy to do without a postback in JavaScript.

c# - in the button click event
C#
label1.Text = "SomeText";


javascript - onclick function of the button
JavaScript
function SomeButtonClick(){
document.getElementById("label1").value = "SomeText";
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900