Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET 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 January 21st, 2005, 03:08 PM
Authorized User
 
Join Date: Aug 2003
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Default CodeBehind for .ascx file isn't working

Beginning asp.net 1.1 with vb.net 2003 -- Chapter 12 summary.

I'm trying to do step 3 in the summary of chapter 12.

my difficulty is that it says you can write the codeBehind file just as we did for all the other pages. However I think this is a mistake in that this is not a page but a control. I have imported all the namespaces for the objects referenced in the NavBar UserControl. However I'm struggling with the reference to the Session variable, I think it need the System.Web.UI.Page namespace imported, but then I get some ambiguous message because I'm importing the System.Web.UI.Control namespace too.

Has anyone successfully done step 3? If so how?

Thanks
 
Old January 21st, 2005, 03:50 PM
Authorized User
 
Join Date: Aug 2003
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Default

got it.

navbar.ascx
Code:
<%@ Control Inherits="Wrox.navBarCodeBehind" Src="navBar.ascx.vb" %>
.....
the book says exactly like the other examples here we need a directive to the "Control" class not the "Page" class like all previous examples.

navbar.ascx.vb
Code:
Imports System
Imports System.DateTime
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.UserControl

Namespace Wrox

    Public Class navBarCodeBehind : Inherits UserControl
Obviously we need to import all namespaces which are referenced in the code but in addition we need to import the System.Web.UI.UserControl namespace and then inherit all characterisitcs from the class "UserControl" into our newly created navBarCodeBehind class -- not quite exactly how we did all previous snippets.

For anyone else going through Beginning ASP.Net 1.1 with vb.net 2003.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Codebehind not working angshujit ASP.NET 1.0 and 1.1 Basics 1 September 21st, 2007 07:32 AM
what is debug directive for codebehind file? lethe ASP.NET 1.0 and 1.1 Basics 4 May 21st, 2007 06:38 PM
Making an Alteration to an VB Codebehind file Nostromo77 ASP.NET 2.0 Basics 4 April 24th, 2007 08:11 PM
Using ascx file or include ajindal Classic ASP Components 1 October 6th, 2004 07:32 AM





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