is not accessible in this context because it is 'Protected'

M

Murphy

I've read through the google posts on this topic and am still unclear of the
solution.

Simply I have a user control that contains form controls and I would like to
reference the values in the form from the aspx page that contains the user
control. The error message received is:
Compiler Error Message: BC30390: 'ASP._userdetails_ascx.Company' is not
accessible in this context because it is 'Protected'.

Thanks

Murphy
 
P

Peter Rilling

You have to wrap access to your form fields using properties or methods, or
make your form fields public.
 
M

Murphy

Thanks Peter,

This is inline with what I discovered in google however I am new to asp.net
and don't understand what this involves.
Does this mean including a including a html "Public" tag in the ascx or
similar ?

Thanks

Murphy
 
P

Peter Rilling

You set the visibility in code, where you define the object. Look in your
code-behind.
 
S

Sharon

Protected means that only the class in which the member is defined
or derived classes, have access to this member.
You must inherit the class or change the member access modifier to Public.
Sharon.
 
M

Murphy

Peter, The object is defined with the following code:

<asp:TextBox id="Company" runat="server" MaxLength="50"
size="50"></asp:TextBox>

As opposed to being defined in vb code such as:

Private Sub CreateMyMultilineTextBox()
' Create an instance of a TextBox control.
Dim textBox1 As New TextBox()

' Set the Multiline property to true.
textBox1.Multiline = True
' Add vertical scroll bars to the TextBox control.
textBox1.ScrollBars = ScrollBars.Vertical
' Allow the RETURN key to be entered in the TextBox control.
textBox1.AcceptsReturn = True
' Allow the TAB key to be entered in the TextBox control.
textBox1.AcceptsTab = True
' Set WordWrap to True to allow text to wrap to the next line.
textBox1.WordWrap = True
' Set the default text of the control.
textBox1.Text = "Welcome!"
End Sub

With the object being set as a web form control how can I make it public ?

Thanks

Murphy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top