CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 2/21/2005 3:34:41 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 11 Views: 27 Favorited: 0 Favorite
12 Items, 1 Pages 1 |< << Go >> >|
lance22
Asp.Net User
User Control from Code Behind Page Failure2/21/2005 3:34:41 AM

0/0

Am trying to make my first REAL user control. The code works great if I keep the functions on the .aspx / .ascx page, but does NOT work at all when I try to have the code on the .vb code-behind page. Can anyone give me the short on why code-behind pages don't like user controls? Does anyone know of a good article on the subject, or is there a code sample around that I can look at? I code in VB. Thanks in advance, lance22.
----------------------------

Ever heard of Wauchula?
llangleyben
Asp.Net User
Re: User Control from Code Behind Page Failure2/21/2005 2:53:38 PM

0/0

Hi Lance,
Can you show us what error do you receive?
Leon Langleyben

MCSD, ASP.NET MVP

Blog
lance22
Asp.Net User
Re: User Control from Code Behind Page Failure2/21/2005 3:15:28 PM

0/0

Error Message: Compiler Error Message: BC30456: 'Street' is not a member of 'System.Web.UI.UserControl'.

It's a mess ... haven't done seperate class for user control, have not compiled any Dll's. All code is in three files, (1) aspx, (2) ascx (3) .vb. The complete code, start to finish:

' ----------- Address.aspx

<%@ Page Language="vb" src="Address.vb" Inherits="cls_addresscontrols" %>
<%@ Register TagPrefix="myUserControl" TagName="ctlAddress"
Src="Address_Controls.ascx" %>
<html>
<head><title>User Controls</title>
<body>
<form Runat="Server">
Billing Address

<myUserControl:ctlAddress
ID="ctlAddress"
Runat="Server" />



<asp:Button
Text="Submit"
OnClick="Button_Click"
Runat="Server" />
<p>
<asp:Label
ID="lblOutput"
Runat="Server" />
</form>
</body>
</html>

' ------------------ Address_Controls.ascx

<p>Street Address:


<asp:TextBox
ID="txtStreet"
Runat="Server" />


City:


<asp:TextBox
ID="txtCity"
Runat="Server" />

' ---------------- Address.vb

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

Public Class cls_addresscontrols
Inherits Page

Protected WithEvents lblOutput As Label
Protected WithEvents txtStreet As Textbox
Protected WithEvents txtCity As TextBox
Protected WithEvents ctlAddress As UserControl

Public Property Street As String
Get
Return txtStreet.Text
End Get
Set
txtStreet.Text = Value
End Set
End Property

Public Property City As String
Get
Return txtCity.Text
End Get
Set
txtCity.Text = Value
End Set
End Property

Private Sub Page_Load(ByVal sender as object, byVal e As EventArgs)
' nothing
End Sub


Sub Button_Click( s As Object, e As EventArgs )
' maybe use directcast findcontrols here ???
lblOutput.Text = "You entered the following:"
lblOutput.Text &= "<li> Street: " & ctlAddress.Street
lblOutput.Text &= "<li> City: " & ctlAddress.City
End Sub

End Class

' --------------- Thanks ...

Thought maybe this was a common problem and somebody would say "ya can't do that unless you make it a business object" or "ya gotta instantiate in the Page_Load event" or ... My apologies as I really don't mean to have anyone write out a complete solution for me ... just wanted a push in the right direction on what I hope is a simple noob problem that everybody has gone through once ..

Thanks in advance,

lance22

----------------------------

Ever heard of Wauchula?
llangleyben
Asp.Net User
Re: User Control from Code Behind Page Failure2/21/2005 4:15:39 PM

0/0

Hi Lance,
Change
Protected WithEvents ctlAddress As UserControl
to
Protected WithEvents ctlAddress As Address_Controls
in page codebehind.
Leon Langleyben

MCSD, ASP.NET MVP

Blog
lance22
Asp.Net User
Re: User Control from Code Behind Page Failure2/21/2005 4:18:31 PM

0/0

Did it .... new error message is:

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

Source Error:

Line 10: Protected WithEvents txtStreet As Textbox
Line 11: Protected WithEvents txtCity As TextBox
Line 12: Protected WithEvents ctlAddress As Address_Controls

All help is greatly appreciated ...



----------------------------

Ever heard of Wauchula?
llangleyben
Asp.Net User
Re: User Control from Code Behind Page Failure2/21/2005 4:31:23 PM

0/0

Can you post <@ Control tag of Address_Controls.ascx?
Leon Langleyben

MCSD, ASP.NET MVP

Blog
lance22
Asp.Net User
Re: User Control from Code Behind Page Failure2/21/2005 4:34:12 PM

0/0

I do not have a @Control tag on Address_Controls.ascx
----------------------------

Ever heard of Wauchula?
lance22
Asp.Net User
Re: User Control from Code Behind Page Failure2/21/2005 4:54:51 PM

0/0

The code that I have posted above is complete, not abreviated, leaves out not a single line of code on any of the three pages ... if something seems missing ... it is.
----------------------------

Ever heard of Wauchula?
llangleyben
Asp.Net User
Re: User Control from Code Behind Page Failure2/21/2005 5:28:10 PM

0/0

Can you post the whole control :) ?
Leon Langleyben

MCSD, ASP.NET MVP

Blog
lance22
Asp.Net User
Re: User Control from Code Behind Page Failure2/21/2005 5:54:19 PM

0/0

Yes, the entire use control is posted above ... There is no form tag, no @control directive, no <html> tag ... just what you see above. The complete code, start to finish, top to bottom, unbridged, for all three pages (aspx, ascx, .vb) are posted in their entirety.

Again ... your continued help is greatly appreciated :) My guess is that I am leaving out something so BASIC that everybody assumes that I must be doing it when in fact I am not ... some tag, directive or other thing that everybody else knows to include that yet eludes me.
----------------------------

Ever heard of Wauchula?
llangleyben
Asp.Net User
Re: User Control from Code Behind Page Failure2/22/2005 9:53:17 AM

0/0

Hi Lance,
Try to add folowing directive as first line of your user control:

<%@ Control Language="vb" ClassName="Address_Controls" >

Let me know :) .
Leon Langleyben

MCSD, ASP.NET MVP

Blog
lance22
Asp.Net User
Re: User Control from Code Behind Page Failure2/22/2005 3:13:59 PM

0/0

Didn't change the error message. I think it's time to stick a fork in it and say it's done. This is like Aesop's fox saying the grapes are sour, but I think for what I'm trying to do, I would be better off writing custom classes and storing them in bin. I thank you very much for your help. If I ever figure out how to do this, I'll post it somewhere ...

Very best regards,

lance22
US of A
----------------------------

Ever heard of Wauchula?
12 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
ASP.NET 2.0 Instant Results Authors: Imar Spaanjaars, Paul Wilton, Shawn Livermore, Pages: 456, Published: 2006
ASP.NET 2.0 Cookbook Authors: Michael A. Kittel, Geoffrey T. LeBlond, Pages: 989, Published: 2005
Building Web Applications with C# and .NET: A Complete Reference Authors: Dudley W. Gill, Pages: 718, Published: 2002
Sams Teach Yourself C# Web Programming in 21 Days Authors: Philip Syme, Peter Aitken, Pages: 535, Published: 2001
C# for Programmers: Updated for C# 2.0 Authors: Paul J. Deitel, Pages: 1317, Published: 2005
Visual Basic 2005: How to Program Authors: Harvey M. Deitel, Pages: 1513, Published: 2006
Mechanics of User Identification and Authentication: Fundamentals of Identity Management Authors: Dobromir Todorov, Pages: 728, Published: 2007
Beginning ASP.NET 2.0 AJAX: Written and Tested with the Final 1.0 Release Version of ASP.NET AJAX for ASP:NET 2.0 Authors: Wallace B. McClure, Paul Glavich, Scott Cate, Steve C. Orr, Craig Shoemaker, Steven A. Smith, Jim Zimmerman, Pages: 344, Published: 2007
The Industrial Information Technology Handbook Authors: Richard Zurawski, Pages: 1936, Published: 2004
Debugging ASP.NET Authors: Jonathan Goodyear, Brian Peek, Brad Fox, Pages: 376, Published: 2001

Web:
Code Behind Approach We have seen that mixing the user interface (HTML) with the programming logic ( JavaScript, .... Code-behind generates code that you do not directly control, ...
Silverlight Tutorial Part 6: Using User Controls to Implement ... We can then handle the "SelectionChanged" event from our ListBox control within the Page.xaml's code-behind class:. When a user selects a particular story ...
Upload File Exception (Logon failure: unknown user name or bad ... IOException: Logon failure: unknown user name and/or bad password. This is the function I'm using for Upoading files in the code behind file ...
CodeProject: Creating an RSS Aggregator User Control in ASP.NET ... Mar 2, 2006 ... This method is located in the RSSAggregator.ascx.cs code-behind. Just follow the directions in ... Mastering Page-UserControl Communication ...
Introduction to Web Forms Pages Flexible because you can add user-created and third party controls to them. ... The generated class for the .aspx page inherits from the code-behind class ...
NUnitAsp FAQ ... page or even a specific user control. We expect you to ignore frames, Javascript, and other client-side issues and focus on testing code-behind logic. ...
ASP.NET General [Archive] - Page 3 - Just Skins Support Forums Page Filter in C# · How to reference UserControl in server code · >4000 characters in a TextBox · Windows-based Authentication problem. ...
Combining JQuery Form Validation and Ajax Submission with ASP.NET Nov 21, 2008 ... Along with its code behind. public partial class CommentResponse : System.Web.UI .UserControl { public string Title { get; set; ...
ASP.NET.4GuysFromRolla.com: Dynamic Web Controls, Postbacks, and ... Sep 29, 2004 ... Failure to explicitly add the controls on each postback will cause the .... NET code-behind classes and OnInit in C# code-behind classes) is ...
Easily Raise Events From ASP.NET ASCX User Controls - Brendan ... We have an aspx page with a codebehind file. And we have a usercontrol: an ascx .... COM startup Intrinsigo, and has had a hand in the failure of numerous ...

Videos:
Objects: they just work Google London Test Automation Conference (LTAC) Google Tech Talks September 8th, 2006 Presenter: Bob Binder
A Googly MySQL Cluster Talk Google TechTalks April 28, 2006 Stewart Smith Stewart Smith works for MySQL AB as a software engineer working on MySQL Cluster. He is an ...
A New Way to look at Networking Google Tech Talks August 30, 2006 Van Jacobson is a Research Fellow at PARC. Prior to that he was Chief Scientist and co-founder of Packet ...
Zero Configuration networking with Bonjour Google TechTalks November 2, 2005 Dr. Stuart Cheshire, Apple Computer http://www.stuartcheshire.org/ ABSTRACT The desirability of making ...




Search This Site:










system.web.ui.webcontrols classes

another tool

usercontrols and page.ispostback

control no longer "draggable and droppable"

saas / application hosting with windows terminalsever 2003

ipostbackdatahandler example code not working

make code controls persistent after a postback!!!

how to read web.config in design-time

ping times problem

removing node from dynamically created tree

comparing panels - dotnet panel - vs- helm - vs -vwdhoting panel

requiredfieldvalidator acts different on 1 server

help, i've fallen (into an admin pit) and i can't get up(dated)...

the best service of asp .net 2.0

looking for your feeback on some interesting topics of discussion

customizing tagprefix !! any idea ???

5 domains on one hosting account? (shared disk space & bandwidth?)

need new compare validator

tracking changes

forms onsubmit() method not called when submit() invoked

composite server control and postback

viewstate object arrays in vb server control

how to access parent container page htmlgenericcontrol

collection properties using persistencemode.innerproperty

discountasp: to tack on the extra $10.00/mo 300mb ms sql or not?

attributes for custom control property

access databases and medium trust

two user controls to talk to each other

dynamically assign css link to a page

eventargs with text/value properties

  Privacy | Contact Us
All Times Are GMT