473,396 Members | 1,683 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,396 software developers and data experts.

Problem accessing User Control fields...

Hello,

I have some user controls on a page...one for the user to fill in name,
address, etc., and the other for the user to fill in credit card
information.

I have built the user controls in exactly the same way in that in the code
behind page, I am using:
Public Property sCVCCode() As String
Get
Return txtSecurityCode.Text
End Get
Set(ByVal Value As String)
txtSecurityCode.Text = Value
End Set
End Property

In my aspx page, I have placed the user controls on the page, and in the
code behind for this page, I have declared my controls like this:
Protected ucRegistrantInfoWithNurse As cforums.RegisantInfoWithNurse
Protected ucPlaceOfEmploymentInfo As cforums.PlaceOfEmploymentInfo
Protected ucCreditCardInfo As cforums.CreditCardInfo

So, now in the code behind I am able to access my fields for name, address,
etc. by using:
ucHomeAddress.sAddress_1

If I set
label1.text = ucHomeAddress.sAddress_1.ToString
my page grabs the address just fine.

BUT...if I try to do this with any part of the Credit Card user control,
like this:
label1.text = ucCreditCardInfo.sCVCCode.ToString

I get the following error:
Object reference not set to an instance of an object.<<


Line 719:
Line 720: Public Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Line 721: Label4.Text = ucCreditCardInfo.sCVCCode.ToString

Any idea why I can access the information from the text fields of one user
control but not the other?

Please let me know if you need any more information.

Thank you for the help,

Lynn
Nov 18 '05 #1
3 1287
Have you included the CreditCard usercontrol in the page HTML?

"Lynn" wrote:
Hello,

I have some user controls on a page...one for the user to fill in name,
address, etc., and the other for the user to fill in credit card
information.

I have built the user controls in exactly the same way in that in the code
behind page, I am using:
Public Property sCVCCode() As String
Get
Return txtSecurityCode.Text
End Get
Set(ByVal Value As String)
txtSecurityCode.Text = Value
End Set
End Property

In my aspx page, I have placed the user controls on the page, and in the
code behind for this page, I have declared my controls like this:
Protected ucRegistrantInfoWithNurse As cforums.RegisantInfoWithNurse
Protected ucPlaceOfEmploymentInfo As cforums.PlaceOfEmploymentInfo
Protected ucCreditCardInfo As cforums.CreditCardInfo

So, now in the code behind I am able to access my fields for name, address,
etc. by using:
ucHomeAddress.sAddress_1

If I set
label1.text = ucHomeAddress.sAddress_1.ToString
my page grabs the address just fine.

BUT...if I try to do this with any part of the Credit Card user control,
like this:
label1.text = ucCreditCardInfo.sCVCCode.ToString

I get the following error:
Object reference not set to an instance of an object.<<


Line 719:
Line 720: Public Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Line 721: Label4.Text = ucCreditCardInfo.sCVCCode.ToString

Any idea why I can access the information from the text fields of one user
control but not the other?

Please let me know if you need any more information.

Thank you for the help,

Lynn

Nov 18 '05 #2
Make sure the Id of the user control in the html and code behind is
identical
--
Kumar Reddi
http://kumarreddi.blogspot.com

"Lynn" <yeltnab1@_NOSPAM_hotmail.com> wrote in message
news:c4********************@comcast.com...
Hello,

I have some user controls on a page...one for the user to fill in name,
address, etc., and the other for the user to fill in credit card
information.

I have built the user controls in exactly the same way in that in the code
behind page, I am using:
Public Property sCVCCode() As String
Get
Return txtSecurityCode.Text
End Get
Set(ByVal Value As String)
txtSecurityCode.Text = Value
End Set
End Property

In my aspx page, I have placed the user controls on the page, and in the
code behind for this page, I have declared my controls like this:
Protected ucRegistrantInfoWithNurse As cforums.RegisantInfoWithNurse
Protected ucPlaceOfEmploymentInfo As cforums.PlaceOfEmploymentInfo
Protected ucCreditCardInfo As cforums.CreditCardInfo

So, now in the code behind I am able to access my fields for name, address, etc. by using:
ucHomeAddress.sAddress_1

If I set
label1.text = ucHomeAddress.sAddress_1.ToString
my page grabs the address just fine.

BUT...if I try to do this with any part of the Credit Card user control,
like this:
label1.text = ucCreditCardInfo.sCVCCode.ToString

I get the following error:
Object reference not set to an instance of an object.<<

Line 719:
Line 720: Public Sub Button1_Click(ByVal sender As System.Object, ByVal

e As System.EventArgs) Handles Button1.Click
Line 721: Label4.Text = ucCreditCardInfo.sCVCCode.ToString

Any idea why I can access the information from the text fields of one user
control but not the other?

Please let me know if you need any more information.

Thank you for the help,

Lynn

Nov 18 '05 #3
Hello,

Thanks for the prompt reply. :)

I was pretty sure I had everything in place correctly, as I was able to get
intellisense to show the exposed fields in the user control.

Anyhow, since it was such a small control, I rebuilt it from scratch, and
inserted into the html again, and it appears to be working fine now. Go
figure.

Thanks!

Lynn

"Lynn" <yeltnab1@_NOSPAM_hotmail.com> wrote in message
news:c4********************@comcast.com...
Hello,

I have some user controls on a page...one for the user to fill in name,
address, etc., and the other for the user to fill in credit card
information.

I have built the user controls in exactly the same way in that in the code
behind page, I am using:
Public Property sCVCCode() As String
Get
Return txtSecurityCode.Text
End Get
Set(ByVal Value As String)
txtSecurityCode.Text = Value
End Set
End Property

In my aspx page, I have placed the user controls on the page, and in the
code behind for this page, I have declared my controls like this:
Protected ucRegistrantInfoWithNurse As cforums.RegisantInfoWithNurse
Protected ucPlaceOfEmploymentInfo As cforums.PlaceOfEmploymentInfo
Protected ucCreditCardInfo As cforums.CreditCardInfo

So, now in the code behind I am able to access my fields for name, address, etc. by using:
ucHomeAddress.sAddress_1

If I set
label1.text = ucHomeAddress.sAddress_1.ToString
my page grabs the address just fine.

BUT...if I try to do this with any part of the Credit Card user control,
like this:
label1.text = ucCreditCardInfo.sCVCCode.ToString

I get the following error:
Object reference not set to an instance of an object.<<

Line 719:
Line 720: Public Sub Button1_Click(ByVal sender As System.Object, ByVal

e As System.EventArgs) Handles Button1.Click
Line 721: Label4.Text = ucCreditCardInfo.sCVCCode.ToString

Any idea why I can access the information from the text fields of one user
control but not the other?

Please let me know if you need any more information.

Thank you for the help,

Lynn

Nov 18 '05 #4

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

Similar topics

3
by: Vivek Sharma | last post by:
Hi, I have created a dropdownlist as a web user control. I am using its multiple instances on the webpage. How do I access the selectedValue of each instance? All the instances have different...
2
by: LarryB | last post by:
Ok. Here is the question. I am writing code to make a multipage form. Each page is loaded from a usercontrol. Now when I get to the final page I would like to access the information on the...
9
by: Anders K. Jacobsen [DK] | last post by:
Hi I have this that adds some usercontrol (UCTodays.ascx) to a placeholder foreach(A a in B){ UCTodays ucline = (UCTodays )LoadControl("UCTodays.ascx");...
2
by: Richard Lionheart | last post by:
Hi All, I generated a WebForm and created a Virtual Directory for it IIS. But I got an error message (shown below) saying something like my app lacked appropriate privileges. David Wang...
1
by: sympatico | last post by:
Hi, We are working on a .NET application. In our project, most of the interfaces use frames. We have a problem accessing previous page using frames. Let us say we have a page A that does not...
2
by: Stu | last post by:
Hi, I am migrating a large app to .Net 2 and am having problems with accessing hidden fields using javascript. As I am using masterpages the control names are prefixed with the control...
7
by: skeddy | last post by:
In a nutshell, I'm trying to dynamically create a select box with ResultSet code in vbscript and then need to be able to access the value of that select box later with a Save button. I've got...
4
by: helenwheelss | last post by:
Access 2003, using a bound form. I'm seeing rather annoying behaviour when editing data in a control with a default value. It only happens when the form is on a new record. A specific...
36
by: beebelbrox | last post by:
Hi, I am new VB programming in Access and I am requesting help with the following code. WIndows OS MSaccess 2003 This code is attached to an unbound form that will display a specific recordset...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
0
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...
0
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...

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.