473,465 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

User Control Help

Can someone tell me what I am doing wrong??? Below you will find a brief
sample of code that I am using that has a User Control. I know that it is a
lot to ask but I am desperate. The error I receive is: OBJECT REFERENCE NOT
SET TO AN INSTANCE OF THE OBJECT

wuc.ascx
Public MustInherit Class wuc

Inherits System.Web.UI.UserControl

Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox

Protected WithEvents Calendar1 As System.Web.UI.WebControls.Calendar


Public ReadOnly Property getDate() As String

Get

Return Me.TextBox1.Text

End Get

End Property

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

End Sub

Private Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Calendar1.SelectionChanged

Me.TextBox1.Text = Me.Calendar1.SelectedDate

End Sub

End Class

HERE IS THE ASPX

Public Class WebForm5

Inherits System.Web.UI.Page

Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox

Protected WithEvents Button1 As System.Web.UI.WebControls.Button

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

End Sub

Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim x As test.wuc

Me.TextBox1.Text = x.getDate()

End Sub

End Class
Jul 21 '05 #1
4 1149

"Julio Sarmiento" <jl*****@bellsouth.net> wrote in message
news:ez**************@tk2msftngp13.phx.gbl...
Can someone tell me what I am doing wrong??? Below you will find a brief
sample of code that I am using that has a User Control. I know that it is a lot to ask but I am desperate. The error I receive is: OBJECT REFERENCE NOT SET TO AN INSTANCE OF THE OBJECT


OK, 2$es
Jul 21 '05 #2
excuse me?
"Murgi" <sr******@da2.so-net.ne.jp> wrote in message
news:2c******************************@news.secureu senet.com...

"Julio Sarmiento" <jl*****@bellsouth.net> wrote in message
news:ez**************@tk2msftngp13.phx.gbl...
Can someone tell me what I am doing wrong??? Below you will find a brief sample of code that I am using that has a User Control. I know that it
is a
lot to ask but I am desperate. The error I receive is: OBJECT REFERENCE

NOT
SET TO AN INSTANCE OF THE OBJECT


OK, 2$es

Jul 21 '05 #3
Julio Sarmiento <jl*****@bellsouth.net> wrote:
Can someone tell me what I am doing wrong??? Below you will find a brief
sample of code that I am using that has a User Control. I know that it is a
lot to ask but I am desperate. The error I receive is: OBJECT REFERENCE NOT
SET TO AN INSTANCE OF THE OBJECT


You're never actually creating an instance of TextBox and assigning a
reference to it to TextBox1. (Same goes for Calendar1.)

That means the variables will have their default null values. When you
try to dereference that null reference, you'll get the exception above.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #4
Where are you assigning memory for TextBox1 and calendar1
using new ?
Jul 21 '05 #5

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

Similar topics

3
by: Tim Thomas | last post by:
Hi, I am very new to .NET and am in the process of building my first web application. I will briefly describe what i am trying to achieve: I have a system where suppliers register their...
13
by: Lloyd Sheen | last post by:
I have now spent 5 hours on google/msdn looking for something useful in the creation of user controls for asp.net. The VS 2003 has very limited support for things such as absolute positioning of...
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
6
by: grist2mill | last post by:
I want to create a standard tool bar that appears on all pages that is a control. The toolbar has a button 'New'. What I wolud like when the user clicks on 'New' depends on the page they are on. I...
5
by: Dave | last post by:
(Second Try) Greetings, I have an asp.net web application that utilizes a User Control at the top of the page. My User Control contains a Server Control menu which will require postbacks. ...
7
by: Smithers | last post by:
I have a non trivial ASP.NET Web application that implements its navigation system via a user control (menu.ascx) placed on every page. It is important to note that the user control that hosts...
3
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
4
by: thomson | last post by:
Hi all, i do have a user control with 4 buttons, and all the events are firing properly, My problem is that i need to right an event handler in the user control, which gets fired after a...
8
by: Paul Bromley | last post by:
I am trying to get somewhere with user controls and have come up against an obstacle with using relative paths. I have a dataset in my user control, and have tried to enter the path with the...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.