russell12
asked on
Functions not working on new pages asp.net
I have a project and the strangest thing is happening. I have been trying to figure it out for multiple hours. The issue is if I create a new web form, the code behind will see all the controls, but from the .aspx page I can use any public functions from the code behind. For example if I create the following function:
Then I go to the .aspx source and put the following:
The following is WebForm5.aspx:
WebForm5.aspx.vb:
I have "older" pages that I can call the exact same function from code behind. Any help would be greatly appreciated as this issue has been a problem for the last 3+ hours. Thanks in advance!!
Public Function Hey()
Return True
End Function
Then I go to the .aspx source and put the following:
<%# hey%>
I get the following error: Error 2 'hey' is not declared. It may be inaccessible due to its protection level.The following is WebForm5.aspx:
<%@ Page Title="Web Form" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="WebForm5.aspx.vb" Inherits="InventoryManagement.WebForm5" Async="true" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%# hey%>
</div>
</form>
</body>
</html>
WebForm5.aspx.vb:
Public Class WebForm5
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Public Function Hey()
Return True
End Function
End Class
I have "older" pages that I can call the exact same function from code behind. Any help would be greatly appreciated as this issue has been a problem for the last 3+ hours. Thanks in advance!!
ASKER
Russ,
Thanks for your response, but this is not the case. In VS2013 as you type, it suggests as you know, and it doesnt suggest any function's in the behind code. But if I add a textbox and name is txtname, and go into code behind and put on load: txtname.text = "My Name" then on page load txtname.text will = "My Name". So it is like the code behind can see the controls on the .aspx page, but the .aspx page can not see the functions in the code behind. If I inherit a class that has been part of the project, then it can see the functions in that class just fine. I have tried to put a new namespace, new class and I am at a lost. I dont know if I have a corruption somewhere that is causing this.
Thanks for your response, but this is not the case. In VS2013 as you type, it suggests as you know, and it doesnt suggest any function's in the behind code. But if I add a textbox and name is txtname, and go into code behind and put on load: txtname.text = "My Name" then on page load txtname.text will = "My Name". So it is like the code behind can see the controls on the .aspx page, but the .aspx page can not see the functions in the code behind. If I inherit a class that has been part of the project, then it can see the functions in that class just fine. I have tried to put a new namespace, new class and I am at a lost. I dont know if I have a corruption somewhere that is causing this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No one else commented on the issue. The issue was a simple clean and rebuild. After doing so, the aspx page could see the code behind public functions.
This is one of those things that I dislike about VB.Net. Even though it's not case sensitive it's a good practice to maintain a consistent case throughout your calls.