0

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?

Community
  • 1
  • 1
tmsimont
  • 2,651
  • 2
  • 25
  • 36
  • 1
    What happens if you put a break point on the page load event? Does the debugger step into the method? – Jon P Jan 21 '14 at 03:04
  • no! it doesn't... hmmmmm – tmsimont Jan 21 '14 at 03:05
  • a message shows "the breakpoint will not currently be hit. The source code is different from the original version" -- what does that mean? – tmsimont Jan 21 '14 at 03:07
  • 1
    That means the browser is running the previous version of your web app. Try to recompile the web app. – ekad Jan 21 '14 at 03:10
  • if i move the break to the `vcode.Text` line the message also includes "Possible causes include: conditional compilation or compiler optimizations" – tmsimont Jan 21 '14 at 03:10
  • 1
    Try right clicking on the project in the soultions tab then clicking "Clean" in the contextual menu. Also try closing and re-opening VS. Some of the temp files for the project may be corrupt. – Jon P Jan 21 '14 at 03:10
  • hmm cleaning the project revealed another error. I think there are other issues going on and the project is not recompiling properly. i will have to call it a night now but I can use the info you have provded. it makes sense now. thank you! – tmsimont Jan 21 '14 at 03:12
  • Also see...http://stackoverflow.com/questions/2468852/the-breakpoint-will-not-currently-be-hit-the-source-code-is-different-from-the – Jon P Jan 21 '14 at 03:12

1 Answers1

0

Try adding a namespace like so:

Namespace MyApp

  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

End Namespace
Aheho
  • 12,622
  • 13
  • 54
  • 83
  • 1
    Your answer doesn't help, OP already stated this: "I also tried setting the AutoEventWireup attribute on the page to true, but no change.. still blank label." – ekad Jan 21 '14 at 03:02