error message "... is not accessible in this context because it is 'Private'. United States
  • 14 years ago

    Im new to I got this message when I try to run my .aspx on web browser. I wrote the code on filename.aspx.vb

    Private Sub SubmitBtn_Click(sender As Object, e As System.EventArgs)' is not accessible in this context because it is 'Private'.


  • 14 years ago

    are you using this method somewhere else also???

  • 14 years ago

    Im creating my code at VB.NET web applications

    here is my code in "filename.aspx.vb"
    Private Sub SubmitBtnClick(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesSubmitBtn.Click
            Message.Text = "test"   'Message is label
     End Sub

    then I called it in "filename.aspx" file

    <asp:button id:"SubmitBtn" onclick="submitBtn

  • 14 years ago

    Hi Kaye
     Better to change the lable Name "Message" into "lblMessage"
     after that u put lblMessage.Text="Test"

    I hope this will solve ur problem

    Hari K


  • 14 years ago

    thanks but it didnt solve the problem

  • 14 years ago

    Hi Kaye
     First you do onethink. You just remove that webForm from ur project. Then U add one Webfor and rename it as per the remove webform Name. and add that button(Dont'do and code in Script and code behind side).
    Finally u call that form.

    If it works fine then u add that button and do the coding and Execute it.
    After that also u are getting error then post that error no and error message.

    we should try to solve ur problem.

    Hari K

  • 14 years ago

    Hello Kaye,

    Well you just change the following in the aspx file:

    <asp:button id:"SubmitBtn" onclick="submitBtn_Click"></asp:button>

    changed to

    <asp:button id:"SubmitBtn" runat="server"></asp:button>

    Reason: As you have already bound an event handler for button click by saying Handles SubmitBtn.Click you do not have to say onclick="submitBtn_Click".

    I guess this should solve your problem.


    Udai K

  • 14 years ago

    Look start from the scratch,

    1. On your webform, place a Label control, name it whatever u want to.

    2. On your webform, place a server button control, name it whatever u want to.

    3. double-click on the button control, and you will be in the code behind file. There put ur code as eg:

    Message.Text="Sample Text"

    4. Compile and run the program, and it will work.


    Done intermingle with the aspx page and codebehind, if u  r given some benefits use them.


    hope solved ur problem.

  • 14 years ago

    Thanks for all the suggestions! Its now working by simply replacing the "Private Sub" to "Public Sub" Smiley Face [:)]

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“We better hurry up and start coding, there are going to be a lot of bugs to fix.”