ASP.Net/Page/Page Load

Материал из .Net Framework эксперт
Версия от 11:53, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

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>



Set Asp Label Text during page load (C#)

<%@ Page Language="C#" %>
<script runat="server">
    void Page_Load()
    {
       Message.Text="The ASP.NET line";
    }
</script>
<html>
<head>
    <title>Inserting ASP.NET code Example</title>
</head>
<body>
    <asp:Label id="Message" runat="server"></asp:Label>
    <br />
</body>
</html>