Is the page loaded first time (VB.net) : Page Load « Page « ASP.Net






Is the page loaded first time (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.Set Asp Label Text during page load (C#)