J
Jeff
I have an ASP.NET web page accessing a SQL database. I've used VS to build
the app and stored it in the eNPTest02 directory of my localhost on my
development machine. The database is on the web. I've found a way that
works on the web, and I'm trying to get it to also work in debug mode in the
IDE. The "on the web" page and my SQL database are hosted by a third party
(on separate servers).
Since debug mode opens IE and loads my page from localhost, since the
database is located at a web URL, and since my development machine has an
always-on DSL connection, I'm hoping there's a way to get this to work.
As far as I can tell, this may be a Page directive issue: src vs codebehind.
But in either case, I can't get this to work in the IDE.
What am I doing wrong?? I'd appreciate your help.
I've tried 4 Page directive variations, differing in how I reference the vb
page and how I inherit the class:
<%@ Page Language="vb" codebehind="eNP02.aspx.vb" autoeventwireup="false"
Inherits="eNPTest02.WebForm1"%>
<%@ Page Language="vb" codebehind="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="eNPTest02.WebForm1"%>
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>
None of the above runs in debug mode in the IDE. The last one runs
successfully on the remote host.
codebehind: Won't run in IDE
Won't run on remote host (Parser Error Message: Could not load type)
IDE views are fine
src: Won't run in IDE
Runs on remote host (if I don't refer to localhost directory - as I'd
expect)
Cannot access form design view in IDE
In more detail, here's what happens with each of the 4 variations (Detailed
Code is provided at the end of this post):
'**********
<%@ Page Language="vb" codebehind="eNP02.aspx.vb" autoeventwireup="false"
Inherits="eNPTest02.WebForm1"%>
Run in IDE (debug mode)
IE opens, loads eNP02.aspx from localhost, and hangs. (Eventually I get a
page cannot be displayed error.) When I step through the
code, the Page_Load event code executes without throwing an exception.
Run on remote host
Parser Error Message: Could not load type 'eNPTest02.WebForm1'.
When I open the project after it's been closed
The Design and HTML views of eNP02.aspx both display fine.
'**********
<%@ Page Language="vb" codebehind="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>
Run in IDE (debug mode)
Parser Error Message: Could not load type 'WebForm1'.
Run on remote host
Parser Error Message: Could not load type 'WebForm1'.
When I open the project after it's been closed
The Design and HTML views of eNP02.aspx both display fine.
'**********
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="eNPTest02.WebForm1"%>
Run in IDE (debug mode)
Parser Error Message: The base type 'eNPTest02.WebForm1' does not exist in
the source file 'eNP02.aspx.vb'.
Run on remote host
Parser Error Message: The base type 'eNPTest02.WebForm1' does not exist in
the source file 'eNP02.aspx.vb'.
When I open the project after it's been closed
The file could not be loaded into the Web Forms designer. Please correct
the following error and then try loading it again: The @
Page or @ Control directive contains a src= attribute, which is not
supported in Visual Studio. Make sure all of the classes used in this
page are built or referenced in the project.
I can load the HTML view of eNP02.aspx, but I cannot access the Design view
'**********
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>
Run in IDE (debug mode)
IE opens, loads eNP02.aspx from localhost, and hangs. (Eventually I get a
page cannot be displayed error.) When I step through the
code, the Page_Load event code executes without throwing an exception.
Run on remote host
Runs successfully. The database connection succeeds, and the datagrid
displays all data.
When I open the project after it's been closed
The file could not be loaded into the Web Forms designer. Please correct
the following error and then try loading it again: The @
Page or @ Control directive contains a src= attribute, which is not
supported in Visual Studio. Make sure all of the classes used in this
page are built or referenced in the project.
I can load the HTML view of eNP02.aspx, but I cannot access the Design
view.
codebehind: Won't run on localhost
Won't run on remote host (Parser Error Message: Could not load type)
IDE views are fine
src: Won't run on localhost
Runs on remote host (if I don't refer to localhost directory - as I'd
expect)
Cannot access form design view in IDE
Code:
'eNP02.aspx - the form:
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<TABLE height="310" cellSpacing="0" cellPadding="0" width="359"
border="0" ms_2d_layout="TRUE">
<TR vAlign="top">
<TD width="359" height="310">
<form id="Form1" method="post" runat="server">
<TABLE height="342" cellSpacing="0" cellPadding="0" width="298"
border="0" ms_2d_layout="TRUE">
<TR vAlign="top">
<TD width="56" height="80"></TD>
<TD width="8"></TD>
<TD width="234"></TD>
</TR>
<TR vAlign="top">
<TD height="128"></TD>
<TD colSpan="2">
<asp:Label id="Label1" runat="server" Width="240px"
Height="96px" BorderStyle="Solid">Test 01 Label</asp:Label></TD>
</TR>
<TR vAlign="top">
<TD colSpan="2" height="134"></TD>
<TD>
<aspataGrid id="dgCustomers"
runat="server"></aspataGrid></TD>
</TR>
</TABLE>
</form>
</TD>
</TR>
</TABLE>
</body>
</HTML>
'eNP02.aspx.vb - the codebehind file
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Data.SqlClient
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents dgCustomers As System.Web.UI.WebControls.DataGrid
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim conMain As SqlConnection
Dim sqlCmd As SqlCommand
Dim strConn As String
Try
strConn = ""
strConn = strConn & "Network Library=dbmssocn;"
strConn = strConn & "Password=myPassword;"
strConn = strConn & "User ID=myUser;"
strConn = strConn & "Initial Catalog=myDB;"
strConn = strConn & "Data Source=000.000.000.000;"
conMain = New SqlConnection(strConn)
sqlCmd = New SqlCommand("SELECT FirstName, LastName FROM
eNPCustomers", conMain)
conMain.Open()
Dim rdrCustomers As SqlDataReader = sqlCmd.ExecuteReader
dgCustomers.DataSource = rdrCustomers
dgCustomers.DataBind()
conMain.Close()
Label1.Text = "Codebehind Works"
Catch ex As Exception
Response.Write(ex.ToString)
End Try
End Sub
End Class
the app and stored it in the eNPTest02 directory of my localhost on my
development machine. The database is on the web. I've found a way that
works on the web, and I'm trying to get it to also work in debug mode in the
IDE. The "on the web" page and my SQL database are hosted by a third party
(on separate servers).
Since debug mode opens IE and loads my page from localhost, since the
database is located at a web URL, and since my development machine has an
always-on DSL connection, I'm hoping there's a way to get this to work.
As far as I can tell, this may be a Page directive issue: src vs codebehind.
But in either case, I can't get this to work in the IDE.
What am I doing wrong?? I'd appreciate your help.
I've tried 4 Page directive variations, differing in how I reference the vb
page and how I inherit the class:
<%@ Page Language="vb" codebehind="eNP02.aspx.vb" autoeventwireup="false"
Inherits="eNPTest02.WebForm1"%>
<%@ Page Language="vb" codebehind="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="eNPTest02.WebForm1"%>
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>
None of the above runs in debug mode in the IDE. The last one runs
successfully on the remote host.
codebehind: Won't run in IDE
Won't run on remote host (Parser Error Message: Could not load type)
IDE views are fine
src: Won't run in IDE
Runs on remote host (if I don't refer to localhost directory - as I'd
expect)
Cannot access form design view in IDE
In more detail, here's what happens with each of the 4 variations (Detailed
Code is provided at the end of this post):
'**********
<%@ Page Language="vb" codebehind="eNP02.aspx.vb" autoeventwireup="false"
Inherits="eNPTest02.WebForm1"%>
Run in IDE (debug mode)
IE opens, loads eNP02.aspx from localhost, and hangs. (Eventually I get a
page cannot be displayed error.) When I step through the
code, the Page_Load event code executes without throwing an exception.
Run on remote host
Parser Error Message: Could not load type 'eNPTest02.WebForm1'.
When I open the project after it's been closed
The Design and HTML views of eNP02.aspx both display fine.
'**********
<%@ Page Language="vb" codebehind="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>
Run in IDE (debug mode)
Parser Error Message: Could not load type 'WebForm1'.
Run on remote host
Parser Error Message: Could not load type 'WebForm1'.
When I open the project after it's been closed
The Design and HTML views of eNP02.aspx both display fine.
'**********
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="eNPTest02.WebForm1"%>
Run in IDE (debug mode)
Parser Error Message: The base type 'eNPTest02.WebForm1' does not exist in
the source file 'eNP02.aspx.vb'.
Run on remote host
Parser Error Message: The base type 'eNPTest02.WebForm1' does not exist in
the source file 'eNP02.aspx.vb'.
When I open the project after it's been closed
The file could not be loaded into the Web Forms designer. Please correct
the following error and then try loading it again: The @
Page or @ Control directive contains a src= attribute, which is not
supported in Visual Studio. Make sure all of the classes used in this
page are built or referenced in the project.
I can load the HTML view of eNP02.aspx, but I cannot access the Design view
'**********
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>
Run in IDE (debug mode)
IE opens, loads eNP02.aspx from localhost, and hangs. (Eventually I get a
page cannot be displayed error.) When I step through the
code, the Page_Load event code executes without throwing an exception.
Run on remote host
Runs successfully. The database connection succeeds, and the datagrid
displays all data.
When I open the project after it's been closed
The file could not be loaded into the Web Forms designer. Please correct
the following error and then try loading it again: The @
Page or @ Control directive contains a src= attribute, which is not
supported in Visual Studio. Make sure all of the classes used in this
page are built or referenced in the project.
I can load the HTML view of eNP02.aspx, but I cannot access the Design
view.
codebehind: Won't run on localhost
Won't run on remote host (Parser Error Message: Could not load type)
IDE views are fine
src: Won't run on localhost
Runs on remote host (if I don't refer to localhost directory - as I'd
expect)
Cannot access form design view in IDE
Code:
'eNP02.aspx - the form:
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<TABLE height="310" cellSpacing="0" cellPadding="0" width="359"
border="0" ms_2d_layout="TRUE">
<TR vAlign="top">
<TD width="359" height="310">
<form id="Form1" method="post" runat="server">
<TABLE height="342" cellSpacing="0" cellPadding="0" width="298"
border="0" ms_2d_layout="TRUE">
<TR vAlign="top">
<TD width="56" height="80"></TD>
<TD width="8"></TD>
<TD width="234"></TD>
</TR>
<TR vAlign="top">
<TD height="128"></TD>
<TD colSpan="2">
<asp:Label id="Label1" runat="server" Width="240px"
Height="96px" BorderStyle="Solid">Test 01 Label</asp:Label></TD>
</TR>
<TR vAlign="top">
<TD colSpan="2" height="134"></TD>
<TD>
<aspataGrid id="dgCustomers"
runat="server"></aspataGrid></TD>
</TR>
</TABLE>
</form>
</TD>
</TR>
</TABLE>
</body>
</HTML>
'eNP02.aspx.vb - the codebehind file
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Data.SqlClient
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents dgCustomers As System.Web.UI.WebControls.DataGrid
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim conMain As SqlConnection
Dim sqlCmd As SqlCommand
Dim strConn As String
Try
strConn = ""
strConn = strConn & "Network Library=dbmssocn;"
strConn = strConn & "Password=myPassword;"
strConn = strConn & "User ID=myUser;"
strConn = strConn & "Initial Catalog=myDB;"
strConn = strConn & "Data Source=000.000.000.000;"
conMain = New SqlConnection(strConn)
sqlCmd = New SqlCommand("SELECT FirstName, LastName FROM
eNPCustomers", conMain)
conMain.Open()
Dim rdrCustomers As SqlDataReader = sqlCmd.ExecuteReader
dgCustomers.DataSource = rdrCustomers
dgCustomers.DataBind()
conMain.Close()
Label1.Text = "Codebehind Works"
Catch ex As Exception
Response.Write(ex.ToString)
End Try
End Sub
End Class