I am trying to design a form using VB.Net for WebForms. I have been following the following link My label's text isn't changing on page_load asp.net. But the solution there is not working for me. I already have Handles Me.Load
defined for my Page_Load
event handler, however the result is a "blank" page, with the HTML output below.
form.aspx:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="form.aspx.vb" Inherits="MyApp.form" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test</title>
</head>
<body>
<asp:Label id="vcode" runat="server" />
</body>
</html>
form.aspx.vb:
Imports System.Web
Public Class form
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
vcode.Text = "Why not?"
End Sub
End Class
HTML Output:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
Test
</title></head>
<body>
<span id="vcode"></span>
</body>
</html>
I suspect it has to do with the Inherits
attribute, but if I take out Page_load
from that class definition, I get an error:
Statement is not valid in a namespace
I also tried setting the AutoEventWireup
attribute on the page to true, but no change.. still blank label.
What am I missing here?