473,748 Members | 10,771 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to declare & access pre-complied usercontrols from page codebehind?


I have a user control with code behind of which two instances are
created/declared in my aspx page. The aspx page has code behind also, as
I need to access methods of the usercontrols on page submit.

I've read several post here and articles on the web on this topic. What
little I have learned from them is that you have to pre-compile the
usercontrol in order to access it in the aspx code behind. I did this,
compiling the usercontrol (CityGeoPosList BoxClass) into an assembly
(CityGeoPosSele ctVB.dll), but I still can't get the app to compile. The
error I'm getting presently is:

Compiler Error Message: BC30002: Type 'CityGeoPosList BoxClass' is not
defined.

Source Error:
Line 12: Public Const dRadiusEarth As Double = 6366.707
Line 13:
Line 14: Public ucCityListBox1 As CityGeoPosListB oxClass
Line 15: Public ucCityListBox2 As CityGeoPosListB oxClass
Line 16:

, which is in Test.vb.

I believe my problems are how I set up the <@Control > and <@Register >
tags in the ascx and asp file, and not understanding how to
declare/reference the usercontrols in the aspx codebehind. So my
questions are:

What needs to go in the <@Control > and <@Register > tags to properly
register and access the assembly and it's usercontrols?

How exactly do you reference the controls in the aspx page code behind?

I'd appreciate any help on what I'm doing wrong here.

Thanks and Regards,
N. Demos
File List:
-----------
CityGeoPosSelec t.ascx (usercontrol)
CityGeoPosSelec t.vb (code behind for usercontrol)
Test.aspx (main page)
Test.vb (code behind for main page)
Here's the relevent code:
---------------------------

'********** CityGeoPosSelec t.ascx **********
<%@ Control language="vb" inherits="CityG eoPosListBoxCla ss"
assembly="CityG eoPosSelectVB" %>

'a listbox and a couple textboxes ...

'********** CityGeoPosSelec t.vb **********
Option Explicit
Option Strict

Imports System
Imports System.Web.UI
Imports System.Web.UI.W ebControls
Imports System.Data
Imports System.IO
Imports System.XML

Namespace GeoPos

Public Class CityGeoPosListB oxClass : Inherits System.Web.UI.U serControl
' Stuff ...
End Class
End Namespace

'********** Test.vb **********
Option Explicit
Option Strict

Imports System
Imports System.Collecti ons
Imports System.Web.UI
Imports System.Web.UI.W ebControls
Imports GeoPos
Public Class TestCodebehind : Inherits Page
Public Const dRadiusEarth As Double = 6366.707

Public ucCityListBox1 As CityGeoPosListB oxClass
Public ucCityListBox2 As CityGeoPosListB oxClass

' Other stuff ...
End Class

'********** Test.aspx **********
<%@ PAGE language="VB" debug="true" SmartNavigation ="true" src="Test.vb"
inherits="TestC odebehind" %>
<%@ Register tagprefix="geo" namespace="GeoP os"
assembly="CityG eoPosSelectVB" %>

<html>
<body>
<form method="post" runat="server">
<geo:CityGeoPos ListBoxClass id="ucCityListB ox1" runat="server" />
<br />

<geo:CityGeoPos ListBoxClass id="ucCityListB ox2" runat="server" />
<br />
</div>
</form>

--
Change "seven" to a digit to email me.
Nov 19 '05 #1
2 1976
To put it simply, just create the user controls in your own projects itself,
and raise event from the user control. Capture these events in the page which
you are using.

"N. Demos" wrote:

I have a user control with code behind of which two instances are
created/declared in my aspx page. The aspx page has code behind also, as
I need to access methods of the usercontrols on page submit.

I've read several post here and articles on the web on this topic. What
little I have learned from them is that you have to pre-compile the
usercontrol in order to access it in the aspx code behind. I did this,
compiling the usercontrol (CityGeoPosList BoxClass) into an assembly
(CityGeoPosSele ctVB.dll), but I still can't get the app to compile. The
error I'm getting presently is:

Compiler Error Message: BC30002: Type 'CityGeoPosList BoxClass' is not
defined.

Source Error:
Line 12: Public Const dRadiusEarth As Double = 6366.707
Line 13:
Line 14: Public ucCityListBox1 As CityGeoPosListB oxClass
Line 15: Public ucCityListBox2 As CityGeoPosListB oxClass
Line 16:

, which is in Test.vb.

I believe my problems are how I set up the <@Control > and <@Register >
tags in the ascx and asp file, and not understanding how to
declare/reference the usercontrols in the aspx codebehind. So my
questions are:

What needs to go in the <@Control > and <@Register > tags to properly
register and access the assembly and it's usercontrols?

How exactly do you reference the controls in the aspx page code behind?

I'd appreciate any help on what I'm doing wrong here.

Thanks and Regards,
N. Demos
File List:
-----------
CityGeoPosSelec t.ascx (usercontrol)
CityGeoPosSelec t.vb (code behind for usercontrol)
Test.aspx (main page)
Test.vb (code behind for main page)
Here's the relevent code:
---------------------------

'********** CityGeoPosSelec t.ascx **********
<%@ Control language="vb" inherits="CityG eoPosListBoxCla ss"
assembly="CityG eoPosSelectVB" %>

'a listbox and a couple textboxes ...

'********** CityGeoPosSelec t.vb **********
Option Explicit
Option Strict

Imports System
Imports System.Web.UI
Imports System.Web.UI.W ebControls
Imports System.Data
Imports System.IO
Imports System.XML

Namespace GeoPos

Public Class CityGeoPosListB oxClass : Inherits System.Web.UI.U serControl
' Stuff ...
End Class
End Namespace

'********** Test.vb **********
Option Explicit
Option Strict

Imports System
Imports System.Collecti ons
Imports System.Web.UI
Imports System.Web.UI.W ebControls
Imports GeoPos
Public Class TestCodebehind : Inherits Page
Public Const dRadiusEarth As Double = 6366.707

Public ucCityListBox1 As CityGeoPosListB oxClass
Public ucCityListBox2 As CityGeoPosListB oxClass

' Other stuff ...
End Class

'********** Test.aspx **********
<%@ PAGE language="VB" debug="true" SmartNavigation ="true" src="Test.vb"
inherits="TestC odebehind" %>
<%@ Register tagprefix="geo" namespace="GeoP os"
assembly="CityG eoPosSelectVB" %>

<html>
<body>
<form method="post" runat="server">
<geo:CityGeoPos ListBoxClass id="ucCityListB ox1" runat="server" />
<br />

<geo:CityGeoPos ListBoxClass id="ucCityListB ox2" runat="server" />
<br />
</div>
</form>

--
Change "seven" to a digit to email me.

Nov 19 '05 #2
Prakash.NET wrote:
To put it simply, just create the user controls in your own projects itself,
and raise event from the user control. Capture these events in the page which
you are using.
Prakash,
Thanks for replying. I'm not sure what you mean by raise events from the
control. I'm somewhat of a beginner with ASP.NET. Also, I'm not using
Visual Studio.

Basically, my usercontrol is an asp:listbox and an asp:textbox, with the
SelectedIndexCh anged event handled on the listbox (which displays the
value of the selected listbox item in the textbox. The page has two of
these usercontrols, another textbox and a submit button. The onclick
event of the submit button gets the values from each of the selected
items in the usercontrol's listboxes, performs a calculation with them
and displays the result in the pages textbox.

Regards,
N. Demos

"N. Demos" wrote:

I have a user control with code behind of which two instances are
created/declared in my aspx page. The aspx page has code behind also, as
I need to access methods of the usercontrols on page submit.

I've read several post here and articles on the web on this topic. What
little I have learned from them is that you have to pre-compile the
usercontrol in order to access it in the aspx code behind. I did this,
compiling the usercontrol (CityGeoPosList BoxClass) into an assembly
(CityGeoPosSe lectVB.dll), but I still can't get the app to compile. The
error I'm getting presently is:

Compiler Error Message: BC30002: Type 'CityGeoPosList BoxClass' is not
defined.

Source Error:
Line 12: Public Const dRadiusEarth As Double = 6366.707
Line 13:
Line 14: Public ucCityListBox1 As CityGeoPosListB oxClass
Line 15: Public ucCityListBox2 As CityGeoPosListB oxClass
Line 16:

, which is in Test.vb.

I believe my problems are how I set up the <@Control > and <@Register >
tags in the ascx and asp file, and not understanding how to
declare/reference the usercontrols in the aspx codebehind. So my
questions are:

What needs to go in the <@Control > and <@Register > tags to properly
register and access the assembly and it's usercontrols?

How exactly do you reference the controls in the aspx page code behind?

I'd appreciate any help on what I'm doing wrong here.

Thanks and Regards,
N. Demos
File List:
-----------
CityGeoPosSel ect.ascx (usercontrol)
CityGeoPosSel ect.vb (code behind for usercontrol)
Test.aspx (main page)
Test.vb (code behind for main page)
Here's the relevent code:
---------------------------

'********** CityGeoPosSelec t.ascx **********
<%@ Control language="vb" inherits="CityG eoPosListBoxCla ss"
assembly="Cit yGeoPosSelectVB " %>

'a listbox and a couple textboxes ...

'********** CityGeoPosSelec t.vb **********
Option Explicit
Option Strict

Imports System
Imports System.Web.UI
Imports System.Web.UI.W ebControls
Imports System.Data
Imports System.IO
Imports System.XML

Namespace GeoPos

Public Class CityGeoPosListB oxClass : Inherits System.Web.UI.U serControl
' Stuff ...
End Class
End Namespace

'********** Test.vb **********
Option Explicit
Option Strict

Imports System
Imports System.Collecti ons
Imports System.Web.UI
Imports System.Web.UI.W ebControls
Imports GeoPos
Public Class TestCodebehind : Inherits Page
Public Const dRadiusEarth As Double = 6366.707

Public ucCityListBox1 As CityGeoPosListB oxClass
Public ucCityListBox2 As CityGeoPosListB oxClass

' Other stuff ...
End Class

'********** Test.aspx **********
<%@ PAGE language="VB" debug="true" SmartNavigation ="true" src="Test.vb"
inherits="Tes tCodebehind" %>
<%@ Register tagprefix="geo" namespace="GeoP os"
assembly="Cit yGeoPosSelectVB " %>

<html>
<body>
<form method="post" runat="server">
<geo:CityGeoPos ListBoxClass id="ucCityListB ox1" runat="server" />
<br />

<geo:CityGeoPos ListBoxClass id="ucCityListB ox2" runat="server" />
<br />
</div>
</form>

--
Change "seven" to a digit to email me.

--
Change "seven" to a digit to email me.
Nov 19 '05 #3

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

Similar topics

22
3313
by: Marc Mones | last post by:
Hello, I'working with IBM DB2 V8.1 and CLI/ODBC. I've got a problem with the following statement: ******************************************************************************** SELECT S_ART, S_SPRACHE, S_MANDANT, S_NR, S_SUB, S_OWNER, S_SATZ FROM SY0001_00005 WHERE S_ART = ? AND S_SPRACHE = ? AND S_MANDANT = ? AND S_NR = ? AND
2
567
by: Earl Anderson | last post by:
In A97, WXP, I have an employee form which, among other things, has a textbox for that employee's assigned access card number . The form also has two (2) Yes/No checkboxes. One checkbox is to indicate whether this is a new number (in the entire system) that needs to be added ("Yes") to a list to be emailed to the property manager and the other checkbox, if checked "Yes", is the basis for another list to have a receipt printed in the...
28
15385
by: Michael B. | last post by:
I tend to use rather descriptive names for parameters, so the old style of declaration appeals to me, as I can keep a declaration within 80 chars: void * newKlElem (frame_size,num_blocks,num_frames,frame_locator) size_t frame_size; unsigned short num_blocks; unsigned short num_frames; Kl_frame_locator *locator; { /* code goes here */
27
3849
by: Daniel Vallstrom | last post by:
I'm having problems with inconsistent floating point behavior resulting in e.g. assert( x > 0.0 && putchar('\n') && x == 0.0 ); holding. (Actually, my problem is the dual one where I get failed assertions for assertions that at first thought ought to hold, but that's not important.) At the end is a full program containing the above seemingly
3
2273
by: Gary B. Levy | last post by:
I need to install (for a developer associate. I am NOT a developer)VB.NET versions 6 & 7 on two dissimilar hardware platforms, both running Windows XP Professional with Service Pack 2. Both are Dell platforms. One is a laptop. One is a tower. 1. Does the "default" install suffice in most cases? 2. Are there any caveats or pitfalls to watch out for? 3. What factors affect the performance of both versions cohabiting with the SAME...
3
4766
by: Rik | last post by:
Hello, first of all, my provider sucks, newsserver is down for the #nth time now, offcourse when I have an urgent question.... So this will be me first time using Google Groups, forgive me if something goes wrong. The problem at hand: In a restricted area I let a user upload an image, no problem The image gets scaled down with imagecopyresampled(), and stored with imagejpeg($resized_img,'/path/to/target/image.jpg')
2
2051
by: freegnu | last post by:
how to declare a friend function that can access two class it will look like the following class A { private: int i; public: A(){} ~A(){} friend void call(A &a, B &b);
2
13458
by: juan.gautier | last post by:
Hi, I try to construct a SQL code for a view to select a specific data from a table, this query take the value of the filter from a text box in a visual basic 6.0 form. my problem is when i DECLARE the variable @AMP receive a error message that said "The Declare cursor SQL construct or statement is not supported." What i do wrong? Please help me. i attach the code. DECLARE @AMP int;
5
5846
by: satish mullapudi | last post by:
Hi All, This is a very general question, not pertaining to any vendor or DBMS. What is the difference between a DBMS & RDBMS ? Can anyone pls provide a detailed explaination on this. Awaiting replies............ Satish...
32
2566
by: Joe | last post by:
I am just starting to use Object Oriented PHP coding, and I am seeing quite often the following (this example taken from a wiki): $wakka =& new Wakka($wakkaConfig); What exactly is the =&, and why is it different from = ?
0
8828
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9537
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9243
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.