Jag försöker förstå Codebehind och jag använder VS.NET. Av någon anledning får jag inte Page_Load till att funka. Här är Codebehind filen: subrutinen submitting saknar på slutet Page_Load tycks inte funka
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents lblMess As System.Web.UI.WebControls.Label
Protected WithEvents lblMess2 As System.Web.UI.WebControls.Label
Protected WithEvents btSubmit As System.Web.UI.WebControls.Button
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim strTestar As String = "Testar"
If Not Page.IsPostBack Then
lblMess.Text = strTestar
End If
End Sub
Sub Submitting(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim strTestar2 As String = "Testar 2"
lblMess2.Text = strTestar2
End Sub
End Class
Och här är aspx filen:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="blogLinda.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Label ID="lblMess" Runat="server" />
<br />
<asp:Label ID="lblMess2" Runat="server" />
<br />
<asp:Button ID="btSubmit" Text="Klicka här" OnClick="Submitting" Runat="server" />
</form>
</body>
</html>Sv: Page_Load tycks inte funka
... ) handles btnsubmit.click