asp:button event to change the label text (VB.net) : Button « Asp Control « ASP.Net






asp:button event to change the label text (VB.net)

<%@ Page Language="VB" %>
<script runat="server">
    Sub Button1_Click(sender As Object, e As EventArgs)
    
      Label2.Text = "The button has been clicked"
    
    End Sub
    
    Sub Page_Load(sender As Object, e As EventArgs)
    
      If Page.IsPostBack Then
        Label1.Text = "The page has been loaded because of a button click"
      Else
        Label1.Text = "The page has been loaded for the first time"
      End If
      Label2.Text = ""
    
    End Sub

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <p>
            <asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Button"></asp:Button>
        </p>
        <p>
            <asp:Label id="Label1" runat="server">Label</asp:Label>
        </p>
        <p>
            <asp:Label id="Label2" runat="server">Label</asp:Label>
        </p>
    </form>
</body>
</html>

           
       








Related examples in the same category

1.Event in code behind file (VB.net)
2.asp:button: command name and arguments (VB.net)
3.Event driven page (VB.net)
4.Set Button text (VB.net)
5.Button action Command and Parameter (VB.net)
6.Add action listener to a server Button (VB.net)
7.asp button postbackurl (C#)
8.asp button on client click (C#)
9.Button counter: click and change button label (C#)
10.Add action listener to asp Button by delegate (C#)
11.Read input and do the calculation in Button action listener (C#)
12.Button event Handler (C#)
13.onmouseover and onmouseout events
14.OnClientClick event
15.CausesValidation="False"