Why is this clearly visible symbol unresolvable? - asp.net

I'm getting an ASP Error, according to Resharper, "Solution MembersOrderEntry.sln
Project MembersOrderEntry
MembersOrderEntry\segovias-abq\Default.aspx:1 Cannot resolve symbol 'segovias-abq'"
In the same Default.aspx file, there is a similar error, "Solution MembersOrderEntry.sln
Project MembersOrderEntry
MembersOrderEntry\segovias-abq\Default.aspx:1 Cannot resolve symbol '_Default'"
Why are these symbols ('segovias-abq' and '_Default') unresolvable? The project contains many files named Default.aspx, with Default.aspx.vb beneath them; most of them throw no errors. But after letting Resharper "fix" funky namespace (where it thought they were wrong), I'm getting four of these errors.
Why are the lion's share of the Default.aspx files able to resolve their parent file, but this one is not? As you can see here, the relationship between the failing one and others are the same (a folder name, with Default.aspx beneath that, and Default.aspx.vb beneath that):
Seashore, SimonLeeman, Stern, Weyand, and many others all work fine.
The entire contents of the failing Default.aspx is:
<%# Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="segovias-abq._Default" title="Web Order Entry" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Order Entry Login Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
...and the Default.aspx.vb for it is:
Partial Class _Default
Inherits Page
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Session("SelectedMenu") = "Home"
Response.Redirect("../Login.aspx?MemberNo=B1212")
End Sub
End Class
OTOH, the entire contents of one of the non-failing Default.aspx is:
<%# Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Weyand._Default" title="Web Order Entry" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Order Entry Login Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
...and its Default.aspx.vb is:
Namespace Weyand
Partial Class _Default
Inherits Page
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Session("SelectedMenu") = "Home"
Response.Redirect("../Login.aspx?MemberNo=031")
End Sub
End Class
End NameSpace
IOW, except for the namespaces, they seem to be identical. But even when I added what would seem to be the one expected:
Namespace segovias-abq
...it changed nothing; I still get, "Cannot resolve symbol 'segovias-abq'"

ReSharper removes hyphens or underscores from namespaces when making the namespace names match their directory paths. During a refactoring, ReSharper will not look at string references unless you allow it.
I believe when you refactored, the hyphen was removed form the segovias-abq namespace but that namespace change does not appear to have been corrected in this portion of Default.aspx:
Inherits="segovias-abq._Default"

Related

Referencing a codebehind function from an ASPX page with a Namespace

I have a very unusual problem and would appreciate help. I have a web application in VS 2019.
I am trying to create a page that runs in its own namespace so I can share it with other websites. Below is a simple sample page and code.
<%# Page Language="vb" AutoEventWireup="false" CodeBehind="test1.aspx.vb" Inherits="xxxx.test1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%= Myfunc1() %>
</div>
</form>
</body>
</html>
Namespace xxxx
Public Class test1
Inherits System.Web.UI.Page
Public Function Myfunc1() As String
Myfunc1 = "Hello"
End Function
End Class
End Namespace
The compilation shows <%= Myfunc1() %> as MyFunc1 not found.
If I remove the "Namespace xxxx" from the code behind and change the Inherits="xxxx.test1" to Inherits "TestWebsite.test1" (TestWebsite is the namespace for the web project and the default setting when you add the test page). This code compiles and works OK.
I would appreciate advice on how I can achive my aim of making the namespace for the page independent of the website project.
Thanks
Paul

Simple ASP.NET with VB.NET - Could not load type

I am a c# guy but I need to get a small vb.net test harness working. For the life of me I can't get this to work, and can't discover why. Here's the aspx:
<%# Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Source Page</title>
</head>
<body>
<form id="form1" runat="server">
</form>
</body>
</html>
And here is the .vb:
Public Class _Default
Inherits System.Web.UI.Page
End Class
Always the error "Could not load type '_Default'." I even turned the folder into a true Application in IIS but it made no difference. What am I missing?
What am I missing?
Try the below two -
If your code-behind contains a namespace then modify your inherits attribute in Page directive as Inherits="namespace._Default".
If it doesn't, simply remove this Inherits attribute from Page Directive.
Changing the Codebehind attributename to CodeFile worked for me:
vb
CodeFile="Default.aspx.vb"
C#
CodeFile="Default.aspx.cs"

Call Web Reference using ASPX page

In visual Studio I've added a WSDL web reference which loads a variety of "methods" for calling a SOAP api. I have a blank aspx page. How do I call these methods loaded by the web reference? I've called the web reference mywsdl.
Here's my code so far:
<%# Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication1.WebForm1" %>
<%# Import Namespace="WebApplication1" %>
<%
End Sub
Private Sub Call_Web_Service_Method()
Dim output
Dim CallWebService As New ServerName.mywsdl()
Dim sGetValue As String = CallWebService.GetSomeValue()
output = sGetValue
End Sub
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%=output%>
</div>
</form>
</body>
</html>
Add the web service as a reference at the top of your code behind web page, instantiate a new instance of it where you need it and use it. The methods should already be exposed as you've successfully imported the .asmx I believe, however if you're not getting data back it might require authentication.
using mywsdl;
mywsdl my = new mywsdl();
or
Imports mywsdl
Dim my = new mywsdl()

BC30451: 'NewsBody' is not declared. It may be inaccessible due to its protection level

Try as i might i cant get past this error. I'm not an ASP.Net developer but due to reasons outside my control have to develop 2-3 pages in ASP.
I'm using Dreamweaver and have the asp.net set to compile at first load.
.aspx File
<%# Page Language="vb" AutoEventWireup="false" Src="Scripts/CurrentNews.aspx.vb" Inherits="NewsFunctionality" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>News</title>
<link rel="stylesheet" type="text/css" href="CSS/NewsLayoutOne.css"/>
</head>
<body>
<div class="OuterDiv" runat="server">
<img id="NewsImage" src="Images/DefaultNews1.png" >
<div id="NewsBody" runat="server">Original Text</div>
</div>
</body>
</html>
.aspv.vb file
' VB Document
public partial Class NewsFunctionality
Inherits System.Web.UI.Page
'On load event for the page linked to this class file
protected sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
NewsBody.InnerHTML = "<p>Dynamic Text Generated.</p>"
End Sub
End Class
Check that 'NewsBody' have been declared within the designer.vb file.
It could look something like this since you are using a div:
protected global::System.Web.UI.HtmlControls.HtmlGenericControl NewsBody;

ASP.Net - VB.Net Custom Namespace for Webpages?

I want to be able to define some namespaced constants on the code-behind of my VB.net pages.
For example,
Namespace MyCompany
Namespace Pages
Partial Public Class Default
Inherits System.Web.UI.Page
Public Const PAGE_NAME As String = "Default.aspx"
End Class
End Namespace
End Namespace
I want to be able to execute code like...
Response.Redirect(MyCompany.Pages.Default.PAGE_NAME)
However, the second page won't compile. The compiler error is "'Pages' is not a member of 'MyCompany'".
Any ideas. I've done the same thing in C# without issue, but VB.Net is giving me fits.
Thanks in advance,
Jason
the main problem is u have used Default try to use _Default
this is your code
<%# Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="MyCompany.Pages._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
vb file code
Namespace MyCompany
Namespace Pages
Partial Class _Default
Inherits System.Web.UI.Page
End Class
End Namespace
End Namespace
second file
<%# Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="MyCompany.Pages.Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<% Response.Redirect(MyCompany.Pages.Default2.PAGE_NAME)%>
</div>
</form>
</body>
</html>
code for second file
Namespace MyCompany
Namespace Pages
Partial Class Default2
Inherits System.Web.UI.Page
Public Const PAGE_NAME As String = "Default.aspx"
End Class
End Namespace
End Namespace

Resources