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

  • Thread starter Thread starter Murphy
  • Start date Start date
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
 
You have to wrap access to your form fields using properties or methods, or
make your form fields public.
 
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
 
You set the visibility in code, where you define the object. Look in your
code-behind.
 
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.
 
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
 
Back
Top