Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 4th, 2004, 06:44 AM
Authorized User
 
Join Date: Jun 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default In the Dark with Visual Studio Components

While there appears to be variations with some code used in the components in Visual Studio and Web Matrix, by just letting Visual studio do It's own thing and adding the code from the book I have components from pages 472 to 491 compiled, however in my 'code behind page, Default.aspx.vb' the component registered into the project References is out of scope.
The code in Paragraph number 12 'public Data as New DataAccessCode()' is listed in the tip as 'type DataAccessCode is not defined'.
Any suggestions on how to bring this object into view?
Many thanks in anticipation.

Edward.

 
Old September 6th, 2004, 11:19 AM
Authorized User
 
Join Date: Jun 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, the following is the code from the top of my Default.aspx.vb file if it helps make thing clearer:

************************************************** *********************
Imports System.Web.Caching
Imports System.DateTime
Imports WroxUnited1
Namespace Wrox
    Public Class DefaultCodeBehind
        Inherits System.Web.UI.Page
        Public DateList As New System.Collections.Hashtable
' Public Data As New DataAccessCode <-- this is the offending line

#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 lnkTeams As System.Web.UI.WebControls.HyperLink
        Protected WithEvents lnkPlayers As System.Web.UI.WebControls.HyperLink
        Protected WithEvents lnkGames As System.Web.UI.WebControls.HyperLink
        Protected WithEvents lnkResults As System.Web.UI.WebControls.HyperLink
        Protected WithEvents EventCalendar As System.Web.UI.WebControls.Calendar
        Protected WithEvents MatchesByDateList As System.Web.UI.WebControls.Repeater
        Protected WithEvents pnlFixtureDetails As System.Web.UI.WebControls.Panel
        Protected WithEvents lblRegister As System.Web.UI.WebControls.Label
        Protected WithEvents txtEmailAddress As System.Web.UI.WebControls.TextBox
        Protected WithEvents btnRegister As System.Web.UI.WebControls.Button
        Protected WithEvents ValidEmail As System.Web.UI.WebControls.RegularExpressionValidat or
        Protected WithEvents lnkMerchandise As System.Web.UI.WebControls.HyperLink
        Protected WithEvents lnkChat As System.Web.UI.WebControls.HyperLink
        Protected WithEvents btnApplyTheme As System.Web.UI.WebControls.Button
        Protected WithEvents chkRememberStylePref As System.Web.UI.WebControls.CheckBox

        '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

Etc.
************************************************** **************************
Any help will be appreciated.

Edward.

 
Old September 6th, 2004, 01:18 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Edward,

Is DataAccessCode inside a separate project? If so, does the project have a default namespace?

You may need to refer to the project as

DataAccessProject.DataAccessCode

where DataAccessProject is the name of your DataAccess Project (duh ;)) or any other (default or manually added) namespace.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old September 7th, 2004, 11:09 AM
Authorized User
 
Join Date: Jun 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar, thanks for responding to my V.S. Topic
The components file (DataAccessCode.vb) is part of the WroxUnited1 project same as the Default.aspx.vb page (code behind) it was comiled seperately from the project using the suggested compile.bat file from the book. The resulting .dll was then added to the project references and can be seen in the Solutions Explorer for the project.
I think I am looking for a bit of code linking the front and 'behind code' pages of Default.aspx, evedently the Imports (Imports System.Web.Caching, Imports System.DateTime, Imports WroxUnited1) is not enough and the error message has similarities to that where links are written for labels, txtboxes & other tools but positioned somewhere before 'Public Data' declaration so that the component DataAccessCode.dll can be seen?
Any suggestions?
Many thanks as always.
Best regards,

Edward.

 
Old September 7th, 2004, 02:43 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Edward,

I am not sure how it can be part of the same project *and* be compiled in a separate DLL. Are you referring with "project" to the code download, or to a Visual Studio .NET Project / Solution?

You'll need to check the explicit and default namespaces of the separate project (explicit namespaces are added to the code; the default namespace is set in the vbproj file) to see what namespace you should import.

But better yet: Open the VS.NET solution file that contains your Web project. Add a new, empty Class Library project to the solution. Next, add the DataLayer .vb file to the Class Project and finally, add a Project Reference to the DataAccess class library in your Web project.

This way, the two projects will be linked together. When you make changes to your code, and recompile, everything will be updated correctly.

Even in the latter scenario, you still need to add something like Imports MyNameSpace.MyDataAccessLayer to your VB files in your Web app.

Cheers,


Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Suicidia ... In Questi Fieri Momenti (Ponchielli) by Maria Callas (Track 11 from the album: Maria Callas: The Voice Within the Heart) What's This?
 
Old September 8th, 2004, 07:33 AM
Authorized User
 
Join Date: Jun 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar, many thanks for your reply to my topic, your reply hasn't actually fingered the problem, but it has made me think about the imports entries and I have found what was missing!
The book gives 'Imports WroxUnited' as that required to link to the reference to the .dll file which may be OK for Web Matrix but in VS.NET 'DataAccessCode()' cannot be seen. The imports requires to be extended to: Imports.WroxUnited1 (the name of my project) .WroxUnited (the name of my Namespace in DataAccessCode) .DataAccessCode - this allows me to write the line 'Public As New WroxUnited.DataAccessCode()' which allows the referenced .dll file to be seen.

I had a go at your suggestion in paragraph 3, re the opening of a parallel project within my Solution'WroxUnited1(projects) however having opened the new project the list of Imports in the dropdown list in my original Default.aspx.vb didn't extend to include the added project - why I ask myself?

Many thanks as always.
Regards,

Edward.

 
Old September 9th, 2004, 02:06 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Edward,

I am not sure I understand what you're trying to do. Usually, there are two ways to expose certain code / functionality to a Web project. Either compile it separately with the Css or Vb compiler (or with VS.NET in a separate Class Library Project). Take the resulting Assembly (a DLL file) and add a reference to it in VS.NET. This way, your project is linked to the compile Dll / Assembly.

If you have the source code of the component / class / control whatever it is you're trying to add, you can add the .vb or .cs file to the current (Web) project. This way, when the Web project is compiled, the source of that file is compiled as well, together with the rest of the Web project's code, into your project's assembly.
This way, you have only 1 assembly: that holds your Web stuff and your component / class / control whatever it was you were adding.

Does this help?

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Someday by Neil Young (Track 7 from the album: Freedom) What's This?
 
Old September 11th, 2004, 06:05 AM
Authorized User
 
Join Date: Jun 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar, thanks again for your response to my topic reply. What I am trying to do is to interpret what is written in the book using a media which is other than that used by the Authors - OK there are similarities but there appears to be variations too.
The method for compiling a component or a control described in the book is the former of the two listed in your response, it is evident that the Component.vb can be written either in the current project being developed or in a completely independent project, at the end of the day we are only interested in the .dll not the .vb file, we need only retain the .vb file for future version changes.
In Visual Studio there are about ten choices of type class files, if we select the class for a component it comes with a whole load of code (baggage) which if you know what this is, can, I am sure, be used to advantage, however, since
there is no reference in the book to this code when adding our component code to the class file two errors are generated, these must be minor errors because the file can still be compiled and will function. The errors relate to 'Overrides' and 'disposing' - if we try to get rid of these errors, code behind in the class creates an escalating set of new errors and it becomes worse than before.
Computer Programming is not an exact science, unlike say physics which is identical over known space, programming depends on a knowledge of what someone in Microsoft or the like has written. Microsoft pass information to authors who
interpret this information to write a book on the subject for people like myself to glean an understanding - we can further misinterpret what is intended and get lost. This process is repeated by other compiler manufacturers and the two are
so dissimilar they become different languages.
A message was said to have been sent to Army Headquarters prior to the charge of the Light Brigade, what was sent was 'Send reinforcements we are about to advance' what was delivered was 'send three and four pence we are going to a dance'.
It would have been nice if Microsoft had included the compiled code into the VS.NET desktop interface, the same as with vb6 or C++6. This business of having to compile the .vb file from the command prompt is a backward step - I know it still happens with java.
I am not out of the woods yet with compiling of class objects in VS.NET and have errors in compiling my CustomMotdControl (see Topic 18964)
We could do with a book on how to interpret VS.NET Help you need to be a IT guru to make much out of it! Hence our reliance
on Wrox.
Does this clarify anything?
Many thanks as always for any assistance with the book and VS.NET

Edward.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Studio 2003 vs. Visual Studio 2005 eitanbarazani C# 2005 4 May 9th, 2006 01:34 AM
Visual Studio .net2003 and Visual Studio 2005 Gert Visual C++ 1 January 24th, 2006 05:10 AM
Visual studio 6 or visual studio .NET chaitannyam Visual C++ 1 November 13th, 2005 09:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.