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

How to refer to textbox in class?

Hi,

I am trying to work out how to make reference to an asp textbox control
within a class, contained in a user control, but receive the following
error...

BC30469: Reference to a non-shared member requires an object reference.

Here is the code...

<%@ Control Language="VB" runat="server" %>
<script language="VB" runat="server">
Public Class clsEnterReport
Inherits System.Web.UI.UserControl

Public Event CancelClick()

Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs)
VisibleForm(false)
End Sub

Sub ReportForm()
VisibleForm(true)
End Sub

Sub CancelReport(sender As Object, e As System.EventArgs)
VisibleForm(false)
RaiseEvent CancelClick()
End Sub

Sub VisibleForm(blnForm as Boolean)
lblAmount.visible = blnForm
txtAmount.visible = blnForm
btnReport.visible = blnForm
btnCancel.visible = blnForm
End Sub
End Class

</script>
<table>
<tr><td class="bodytext"><asp:label ID="lblAmount" runat="server"
Text="Amount:" /></td>
<td class="bodytext"><asp:textbox runat="server" ID="txtAmount"
/></td></tr>
<tr><td class="bodytext"><asp:button ID="btnReport" runat="server"
Text="Submit Report" CssClass="btnClass" /></td><td
class="bodytext"><asp:button ID="btnCancel" runat="server" Text="Cancel"
CssClass="btnClass" OnClick="CancelReport" /></td></tr>
</table>

..
..
..
Any assistance would be very much appreciated!!!!

Thanks

john.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
3 2488
hi
try to declare your procedure with shared
ex: public shared sub myproc()
end sub
"John Mason" wrote:
Hi,

I am trying to work out how to make reference to an asp textbox control
within a class, contained in a user control, but receive the following
error...

BC30469: Reference to a non-shared member requires an object reference.

Here is the code...

<%@ Control Language="VB" runat="server" %>
<script language="VB" runat="server">
Public Class clsEnterReport
Inherits System.Web.UI.UserControl

Public Event CancelClick()

Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs)
VisibleForm(false)
End Sub

Sub ReportForm()
VisibleForm(true)
End Sub

Sub CancelReport(sender As Object, e As System.EventArgs)
VisibleForm(false)
RaiseEvent CancelClick()
End Sub

Sub VisibleForm(blnForm as Boolean)
lblAmount.visible = blnForm
txtAmount.visible = blnForm
btnReport.visible = blnForm
btnCancel.visible = blnForm
End Sub
End Class

</script>
<table>
<tr><td class="bodytext"><asp:label ID="lblAmount" runat="server"
Text="Amount:" /></td>
<td class="bodytext"><asp:textbox runat="server" ID="txtAmount"
/></td></tr>
<tr><td class="bodytext"><asp:button ID="btnReport" runat="server"
Text="Submit Report" CssClass="btnClass" /></td><td
class="bodytext"><asp:button ID="btnCancel" runat="server" Text="Cancel"
CssClass="btnClass" OnClick="CancelReport" /></td></tr>
</table>

..
..
..
Any assistance would be very much appreciated!!!!

Thanks

john.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #2
You can declare your textbox as Shared or Public (by default, Visual Studio
declares it as Protected.

Alternatively you can create a public property within the control that
returns a reference to the textbox. You can then use this property to
reference the textbox.

Alan

"John Mason" wrote:
Hi,

I am trying to work out how to make reference to an asp textbox control
within a class, contained in a user control, but receive the following
error...

BC30469: Reference to a non-shared member requires an object reference.

Here is the code...

<%@ Control Language="VB" runat="server" %>
<script language="VB" runat="server">
Public Class clsEnterReport
Inherits System.Web.UI.UserControl

Public Event CancelClick()

Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs)
VisibleForm(false)
End Sub

Sub ReportForm()
VisibleForm(true)
End Sub

Sub CancelReport(sender As Object, e As System.EventArgs)
VisibleForm(false)
RaiseEvent CancelClick()
End Sub

Sub VisibleForm(blnForm as Boolean)
lblAmount.visible = blnForm
txtAmount.visible = blnForm
btnReport.visible = blnForm
btnCancel.visible = blnForm
End Sub
End Class

</script>
<table>
<tr><td class="bodytext"><asp:label ID="lblAmount" runat="server"
Text="Amount:" /></td>
<td class="bodytext"><asp:textbox runat="server" ID="txtAmount"
/></td></tr>
<tr><td class="bodytext"><asp:button ID="btnReport" runat="server"
Text="Submit Report" CssClass="btnClass" /></td><td
class="bodytext"><asp:button ID="btnCancel" runat="server" Text="Cancel"
CssClass="btnClass" OnClick="CancelReport" /></td></tr>
</table>

..
..
..
Any assistance would be very much appreciated!!!!

Thanks

john.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #3
John,

You can use Page.FindControl() to get a reference to a control which
effectively bypasses the visibility of the control in relation to the form.

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
http://www.west-wind.com/wwThreads/
----------------------------------
Making waves on the Web
"John Mason" <jo**@wollondilly.org> wrote in message
news:eX**************@tk2msftngp13.phx.gbl...
Hi,

I am trying to work out how to make reference to an asp textbox control
within a class, contained in a user control, but receive the following
error...

BC30469: Reference to a non-shared member requires an object reference.

Here is the code...

<%@ Control Language="VB" runat="server" %>
<script language="VB" runat="server">
Public Class clsEnterReport
Inherits System.Web.UI.UserControl

Public Event CancelClick()

Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs)
VisibleForm(false)
End Sub

Sub ReportForm()
VisibleForm(true)
End Sub

Sub CancelReport(sender As Object, e As System.EventArgs)
VisibleForm(false)
RaiseEvent CancelClick()
End Sub

Sub VisibleForm(blnForm as Boolean)
lblAmount.visible = blnForm
txtAmount.visible = blnForm
btnReport.visible = blnForm
btnCancel.visible = blnForm
End Sub
End Class

</script>
<table>
<tr><td class="bodytext"><asp:label ID="lblAmount" runat="server"
Text="Amount:" /></td>
<td class="bodytext"><asp:textbox runat="server" ID="txtAmount"
/></td></tr>
<tr><td class="bodytext"><asp:button ID="btnReport" runat="server"
Text="Submit Report" CssClass="btnClass" /></td><td
class="bodytext"><asp:button ID="btnCancel" runat="server" Text="Cancel"
CssClass="btnClass" OnClick="CancelReport" /></td></tr>
</table>

.
.
.
Any assistance would be very much appreciated!!!!

Thanks

john.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #4

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

Similar topics

3
by: Joshua Ammann | last post by:
Hi, (Using Access 2000) I have two tables, similar to Customers and Orders. (Not an exact parallel, but works for this example.) On a form showing customer data, there is a tab control. One...
8
by: jan Veenstra | last post by:
Hi, I am having two problems with Access 97. These '2 problems are posted seperately in this newsgroup. Here's the first: I have a form with lots of similar textboxes and I have a procedure...
1
by: Epson Barnett | last post by:
Hi, I'm new to C# and I'd like to be able to reference a field of an object using a variable instead of literal text. In the PHP scripting language, you can create a variable: $var = "name";...
4
by: Rodrigo DeJuana | last post by:
Howdy, I'm new to this .net stuff and really have little to no training. Im trying to create a new page for a web form, so i have been pretty much jsut coping code. I having some issue with...
4
by: ad | last post by:
I have a string variable string sID; sID store the ID of a TextBox. I want to refer TextBox throw sID. like (TextBox which ID is sID).Text="text"; How can I do that ?
1
by: Paul | last post by:
I have a MDI container form "frmParent". On that form there is a tabstrip control with 2 pages. On one of those pages there is a textbox and a button. When the user clicks on the button a...
2
by: Mamatha | last post by:
Hi I want to add an icon to the textbox's text. I don't know how to display icon in textbox in VB.NET. If any one knows please let me know. Thanks in advance. Mamatha
10
by: Bill Nguyen | last post by:
I have several textbox controls in a form,. I name them txt1, txt2, ... txt10. How dow I refer to them in a loop to get the value in text proerty of each control? For x = 1 to 10 value =...
0
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
1
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
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.