By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,162 Members | 1,099 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,162 IT Pros & Developers. It's quick & easy.

Dealing with user controls and passing info between them

P: n/a
I am having some difficulty in understanding how to deal with variables,
session states, objects, user controls while attempting to develop a ASP.Net
application. I have created several user controls which consist of dropdown
and textbox controls on a panel.

In order for one user control to access a control on another usercontrol, I
have to change the WithEvents to "Protected Shared". That will allow a sub
to access a control on a different user control such as:

Sub This
usercontrol1.textbox1.text = usercontrol2.textbox1.text
end sub

The problem I have is when I change the WithEvents, then all of my handlers
must be shared, and any subs or functions within the handler event also have
to be shared. Then when I change the subs and functions to shared, the blue
squiggly underline goes away from the constructor(?) but then things like
session have the blue squiggly underline saying that:
"Cannot refer to an instance member of a class from within a shared method
or shared member initializer without an explicit instance of the class."

(This usually happens with session variables)
Then I try to create an explicit member of the class by adding the line:
Dim session As Web.SessionState.HttpSessionState
Which takes care of my error but then when I try to run the application I
get the following error in my browser when I attempt to run my code.
"Object reference not set to an instance of an object."

I am not sure what is going on here. Could anyone point me in the right
direction? I do not mind reading, but I am not sure where to begin ...

Thank you,
Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.