473,320 Members | 1,978 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,320 software developers and data experts.

Procedure not accessible when private in webform

If I declare a procedure in a webform as Public and attach it to a button in
the same webform, it runs fine. If I change it to Private Sub and try to
click it i get the error:

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

What am I doing wrong? Everything is in one webform.

Private worked in my notepad version of the project. Why is it not working
in my vsnet version?

Thanks
Nov 18 '05 #1
3 1933
> If I declare a procedure in a webform as Public and attach it to a button in
the same webform, it runs fine. If I change it to Private Sub and try to
click it i get the error:

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

What am I doing wrong? Everything is in one webform.
When the ASP.NET Web page is visited, it is turned into a class that is
*DERIVED* from the code-behind class (which is, in turn, inherited from
the System.Web.UI.Page class). So, the code-behind class becomes a base
class for the actual class that is executed. Inheritence, as you may
know, keeps private members private, but protected and public members
inherit through. So your event handlers need to be protected or public
when using the code-behind model.
Private worked in my notepad version of the project. Why is it not working
in my vsnet version?


In the model where you have the code in a server-side script block, the
class autogenerated is derived directly from the Page class, with the
methods in the server-side script block embedded directly in the
autogenerated class. So they can be private.

For more information, see:

The ASP.NET Page Object Model
http://msdn.microsoft.com/library/de...bjectmodel.asp

Happy Programming!

--

Scott Mitchell
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
Nov 18 '05 #2
If you're using a CodeBehind class, the Page Template inherits it, which
means that Private CodeBehind members will not be accessible to the Page
Template. Make it Protected instead.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Tim Zych" <tzych@earth_noworms_link_dotttt.net> wrote in message
news:#Z**************@tk2msftngp13.phx.gbl...
If I declare a procedure in a webform as Public and attach it to a button in the same webform, it runs fine. If I change it to Private Sub and try to
click it i get the error:

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

What am I doing wrong? Everything is in one webform.

Private worked in my notepad version of the project. Why is it not working
in my vsnet version?

Thanks

Nov 18 '05 #3
Thank you Kevin and Scott.
Tim

"Tim Zych" <tzych@earth_noworms_link_dotttt.net> wrote in message
news:#Z**************@tk2msftngp13.phx.gbl...
If I declare a procedure in a webform as Public and attach it to a button in the same webform, it runs fine. If I change it to Private Sub and try to
click it i get the error:

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

What am I doing wrong? Everything is in one webform.

Private worked in my notepad version of the project. Why is it not working
in my vsnet version?

Thanks

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
7
by: Samantha Penhale | last post by:
Hello, Thanks in advance for any insight you can offer. I've a ASP.NET project written in C#, two web forms, a lovely gob of using statements. I originally had one webform with all my fields and...
1
by: nicholas | last post by:
Anyone can help me with creating a stored procedure that is only executed when the form is submitted? So, I have a form that should inserts values in a table. This goes with a stored procedure....
3
by: Tim::.. | last post by:
Can someone please tell me why I'm getting the following error! I have absolutely no idea why this error keeps appearing! Thanks for any help! Compiler Error Message: BC30390:...
8
by: utterberg | last post by:
Hi I'm adding two dropdownlist in my webform by clicking a button. I fill the first dropdown with some values from my DB and the other one when I choose from the first dropdown. But since theese...
3
by: ABC | last post by:
What methods can export excel file from stored procedure with parameters which input from web form?
1
by: Kevin R | last post by:
This is one of the weirdest problems I have ever run into. I have had to trim down a bunch of code to give a sample that is more easily readable by those who will view this. Here is the problem:...
7
by: Siv | last post by:
Hi, I have a stored procedure that I want to execute and then wait in a loop showing a timer whilst it completes and then carry on once I get notification that it has completed. The main reason...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.