473,320 Members | 2,080 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

code-behind error in user control

In ASP.NET Unleashed (pp. 274-275) There is a sample
DisplayFeaturedProductCodeBehind.aspx:

<Script runat="Server">

Sub Page_Load
Dim strFeatured As String
Dim RanNum As New Random
Dim ctlControl As Control

strFeatured = "Featured" & RanNum.Next( 1, 3 ) & ".ascx"
ctlControl = LoadControl( strFeatured )
Ctype( ctlControl, FeaturedProduct ).BackColor="Orange"
plhFeatured.Controls.Add( ctlControl )
End Sub

</Script>

<html>
<head><title>DisplayFeaturedProductCodeBehind.aspx </title></head>
<body>

<asp:PlaceHolder
id="plhFeatured"
Runat="Server" />

</body>
</html>
Featured1.ascx has the following content: (Featured2.ascx is similar)

<%@ Inherits="FeaturedProduct" %>

<table width="200" cellpadding="10"
cellspacing="0" bgcolor="<%=BackColor%>">
<tr>
<td>
<h3>Hammers on Sale!</h2>
Quality hammers are now on sale in the
hardware department.
</td>
</tr>
</table>
FeaturedProduct.vb has the following:

Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls

Public Class FeaturedProduct
Inherits UserControl

Public BackColor As String = "lightgreen"

End Class

When I try to run it I get the following error. Any idea what is wrong?
I
have recompiled the FeaturedProduct.vb code behind and made sure that
it is
in the bin directory but I still get the error.

Compiler Error Message: BC30002: Type 'FeaturedProduct' is not defined.

Source Error:

Line 8: strFeatured = "Featured" & RanNum.Next( 1, 3 ) & ".ascx"
Line 9: ctlControl = LoadControl( strFeatured )
Line 10: Ctype( ctlControl, FeaturedProduct ).BackColor="Orange"
Line 11: plhFeatured.Controls.Add( ctlControl )
Line 12: End Sub
Source File:
c:\inetpub\wwwroot\unleashed\chapter05\vb\DisplayF eaturedProductCodeBehind.aspx
Line: 10

Aug 22 '06 #1
1 962
OK. The bin directory needs to be placed directly under the wwwroot
directory; or directly under the virtual directory. That's it!

Aug 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

51
by: Mudge | last post by:
Please, someone, tell me why OO in PHP is better than procedural.
4
by: jason | last post by:
Hello. Newbie on SQL and suffering through this. I have two tables created as such: drop table table1; go drop table table2; go
16
by: Dario de Judicibus | last post by:
I'm getting crazy. Look at this code: #include <string.h> #include <stdio.h> #include <iostream.h> using namespace std ; char ini_code = {0xFF, 0xFE} ; char line_sep = {0x20, 0x28} ;
5
by: ED | last post by:
I currently have vba code that ranks employees based on their average job time ordered by their region, zone, and job code. I currently have vba code that will cycle through a query and ranks each...
4
by: KenFehling | last post by:
Hello. I am wondering if there exists a piece of software that takes multiple .js files that are nicely indented and commented and create one big tightly packed .js file. I'm hoping the one file...
7
by: blackrosezy | last post by:
#include char *code; void main() { char buf = "book";
6
by: Fuzzyman | last post by:
Hello all, I'm trying to extract the code object from a function, and exec it without explicitly passing parameters. The code object 'knows' it expects to receive paramaters. It's 'arg_count'...
1
by: ahammad | last post by:
Hello, I have written a fairly complex parsing tool that is used to parse information from company documents. The program works very well, but in order to insure that all the data is copied...
66
by: Jon Skeet [C# MVP] | last post by:
I'm sure the net will be buzzing with this news fairly soon, but just in case anyone hasn't seen it yet: Microsoft are going to make the source code for the .NET framework (parts of it,...
2
by: AccessCoder | last post by:
What is the proper way to reference code snippets that are copied from usenet group examples? What about when a developer posts code that is copyrighted and they allow you to use it in a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.