Pergunta

Getting straight to the point, I've been searching around and can't find a solution to this. I have an ASP.NET web page with a VB code behind that isn't entering the Page_Load Sub.

I've read suggestions regarding adding "Handles Me.Load" to the Sub or checking the AutoEventWireup(tried setting it true, it's currently set to false).

I'm not finding anything so any help is appreciated in advance. Below is some of the code.

Front End:

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/MasterPage.Master" CodeBehind="ThisPage.aspx.vb" Inherits="Project.ThisPage" %>
<asp:Content ID="Content" ContentPlaceHolderID="ContentPH" runat="server">
    <%-- insert content here --%>
</asp:Content>

Back End:

Partial Public Class ThisPage
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ' Insert logic here
    End Sub

End Class

I assume other code shouldn't be necessary as the only thing happening is some variables are being set and assigned to a control that's on the page. If that's not the case I can add more. I tried setting a break point and it's just never entering the sub.

Foi útil?

Solução

If this is a partial class, the aspx page should inherits from the base class. Suppose the base class is Base1, then try change the .aspx file line

Inherits="Project.ThisPage"

to

Inherits="Base1"

Outras dicas

This happened to me today. It turned out that a colleague committed an .aspx file that had a call to a code-behind function that didn't exist. A broken commit in other words. I pulled the code and it built without errors in VS2015 but when the broken page was due to load, the browser reported that it couldn't find it. A breakpoint in page_load wasn't hit. There was nothing to debug. It took me a while to figure it out (which is how I found myself here), so I'm adding this answer in case someone else has the same problem.

I had just upgraded to Windows 8.1 from Windows 7 and Visual Studio selected the wrong project in the solution as the StartUp project. Selecting the correct project resolved the issue.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top