473,396 Members | 1,724 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.

Accessing Web User Control Values From ASPX Code Behind

Does anyone know how to do this?

cntHeader is my control.

When I try to set the value of lblDistributor = label1.text, I get the
following error.

Object reference not set to an instance of an object

PLEASE HELP!

Here is my current code:

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

Dim strSQL As String

Dim rs As ADODB.Recordset

Dim rsUser As ADODB.Recordset

Dim cntHeader As headerinfo

strSQL = "EXEC mf_Partners.dbo.spTblDistributors_Select_ByDistrib utorID " &
Session("DistID") & ""

rs = Global.ReturnRS(strSQL)

strSQL = "EXEC mf_Partners.dbo.spTblDistributorsContacts_Select " &
Session("DistID") & ", '" & Session("UserID") & "'"

rsUser = Global.ReturnRS(strSQL)

If Not rs.EOF Then

HEditProfile.NavigateUrl = "acct_edit.aspx?Email=" & Session("UserID") & ""

HOrderMaterial.NavigateUrl =
"http://www.jacksongroup.com/modernfold/WebLogin.asp?GRP=" & _

Trim$(rs("MaterialCode").Value & "") & "&DST=" & Session("DistID") & _

"&FNAME=" & Trim$(rsUser("UserFName").Value & "") & "&LNAME=" &
Trim$(rsUser("UserLName").Value & "") & _

"&ADDR=" & Trim$(rs("Address1").Value & "") & "&CITY=" &
Trim$(rs("City").Value & "") & _

"&ZIP=" & Trim$(rs("ZipCode").Value & "") & "&PHONE=" &
Trim$(rs("Phone").Value & "") & "&EMAIL=" & _

Session("UserID") & ""

End If

rs.Close()

rs = Nothing

rsUser.Close()

rsUser = Nothing

Label1.Text = cntHeader.lblDistributorName.Text

End Sub
Nov 22 '05 #1
1 1536
This error means that the control has not been created by the time Page Load
happens. Make sure that the lable runat="server" is set. Also make sure it
has a matching ID tag.

David

======================================
David McCarter
www.vsdntips.com
VSDN Tips & Tricks .NET Coding Standards available at:
www.cafepress.com/vsdntips.20412485
"Jason" wrote:
Does anyone know how to do this?

cntHeader is my control.

When I try to set the value of lblDistributor = label1.text, I get the
following error.

Object reference not set to an instance of an object

PLEASE HELP!

Here is my current code:

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

Dim strSQL As String

Dim rs As ADODB.Recordset

Dim rsUser As ADODB.Recordset

Dim cntHeader As headerinfo

strSQL = "EXEC mf_Partners.dbo.spTblDistributors_Select_ByDistrib utorID " &
Session("DistID") & ""

rs = Global.ReturnRS(strSQL)

strSQL = "EXEC mf_Partners.dbo.spTblDistributorsContacts_Select " &
Session("DistID") & ", '" & Session("UserID") & "'"

rsUser = Global.ReturnRS(strSQL)

If Not rs.EOF Then

HEditProfile.NavigateUrl = "acct_edit.aspx?Email=" & Session("UserID") & ""

HOrderMaterial.NavigateUrl =
"http://www.jacksongroup.com/modernfold/WebLogin.asp?GRP=" & _

Trim$(rs("MaterialCode").Value & "") & "&DST=" & Session("DistID") & _

"&FNAME=" & Trim$(rsUser("UserFName").Value & "") & "&LNAME=" &
Trim$(rsUser("UserLName").Value & "") & _

"&ADDR=" & Trim$(rs("Address1").Value & "") & "&CITY=" &
Trim$(rs("City").Value & "") & _

"&ZIP=" & Trim$(rs("ZipCode").Value & "") & "&PHONE=" &
Trim$(rs("Phone").Value & "") & "&EMAIL=" & _

Session("UserID") & ""

End If

rs.Close()

rs = Nothing

rsUser.Close()

rsUser = Nothing

Label1.Text = cntHeader.lblDistributorName.Text

End Sub

Nov 22 '05 #2

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...
0
by: Zi | last post by:
I have a user control within a data grid. I am binding the user control to one of the values from the data grid. The data grid implements paging. It is all working ok for the first page but once i...
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"...
1
by: Robert Howells | last post by:
Perhaps I'm just too new at this to pull it off, or perhaps it's just bad architecture. I'd appreciate some feedback on the the wisdom (or lack thereof) in attempting the following: I'm not new...
3
by: Ryan Taylor | last post by:
Hi. I need to be able to access a public code behind variable within my ASPX page. The reason is that I have a user control "Header" which defines a table layout, and is included in all my...
3
by: Lynn | last post by:
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...
3
by: Craig G | last post by:
i have a user control which is basically a datagrid, which has add/edit/delete buttons on the grid is there anyway of accessing the actual datagrid from the form itself? basically i want to...
10
by: sqlboy2000 | last post by:
Hello all, I have something very simple going on here and I'm scratching my head as to what the problem is. There are 4 items in my project, 2 webforms, a user control, and a module: ...
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
8
by: GaryDean | last post by:
I have a Wizard page and need to affect the next and previous buttons from my code-behind. I've googled around and found two solutions, and neither appear to work. I can access the SideBarList...
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:
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
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
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
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,...

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.