473,698 Members | 2,576 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.U serControl

Public Event CancelClick()

Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s)
VisibleForm(fal se)
End Sub

Sub ReportForm()
VisibleForm(tru e)
End Sub

Sub CancelReport(se nder As Object, e As System.EventArg s)
VisibleForm(fal se)
RaiseEvent CancelClick()
End Sub

Sub VisibleForm(bln Form as Boolean)
lblAmount.visib le = blnForm
txtAmount.visib le = blnForm
btnReport.visib le = blnForm
btnCancel.visib le = blnForm
End Sub
End Class

</script>
<table>
<tr><td class="bodytext "><asp:labe l ID="lblAmount" runat="server"
Text="Amount:" /></td>
<td class="bodytext "><asp:text box runat="server" ID="txtAmount"
/></td></tr>
<tr><td class="bodytext "><asp:butt on ID="btnReport" runat="server"
Text="Submit Report" CssClass="btnCl ass" /></td><td
class="bodytext "><asp:butt on ID="btnCancel" runat="server" Text="Cancel"
CssClass="btnCl ass" OnClick="Cancel Report" /></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 2500
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.U serControl

Public Event CancelClick()

Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s)
VisibleForm(fal se)
End Sub

Sub ReportForm()
VisibleForm(tru e)
End Sub

Sub CancelReport(se nder As Object, e As System.EventArg s)
VisibleForm(fal se)
RaiseEvent CancelClick()
End Sub

Sub VisibleForm(bln Form as Boolean)
lblAmount.visib le = blnForm
txtAmount.visib le = blnForm
btnReport.visib le = blnForm
btnCancel.visib le = blnForm
End Sub
End Class

</script>
<table>
<tr><td class="bodytext "><asp:labe l ID="lblAmount" runat="server"
Text="Amount:" /></td>
<td class="bodytext "><asp:text box runat="server" ID="txtAmount"
/></td></tr>
<tr><td class="bodytext "><asp:butt on ID="btnReport" runat="server"
Text="Submit Report" CssClass="btnCl ass" /></td><td
class="bodytext "><asp:butt on ID="btnCancel" runat="server" Text="Cancel"
CssClass="btnCl ass" OnClick="Cancel Report" /></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.U serControl

Public Event CancelClick()

Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s)
VisibleForm(fal se)
End Sub

Sub ReportForm()
VisibleForm(tru e)
End Sub

Sub CancelReport(se nder As Object, e As System.EventArg s)
VisibleForm(fal se)
RaiseEvent CancelClick()
End Sub

Sub VisibleForm(bln Form as Boolean)
lblAmount.visib le = blnForm
txtAmount.visib le = blnForm
btnReport.visib le = blnForm
btnCancel.visib le = blnForm
End Sub
End Class

</script>
<table>
<tr><td class="bodytext "><asp:labe l ID="lblAmount" runat="server"
Text="Amount:" /></td>
<td class="bodytext "><asp:text box runat="server" ID="txtAmount"
/></td></tr>
<tr><td class="bodytext "><asp:butt on ID="btnReport" runat="server"
Text="Submit Report" CssClass="btnCl ass" /></td><td
class="bodytext "><asp:butt on ID="btnCancel" runat="server" Text="Cancel"
CssClass="btnCl ass" OnClick="Cancel Report" /></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.FindContro l() 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**@wollondil ly.org> wrote in message
news:eX******** ******@tk2msftn gp13.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.U serControl

Public Event CancelClick()

Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s)
VisibleForm(fal se)
End Sub

Sub ReportForm()
VisibleForm(tru e)
End Sub

Sub CancelReport(se nder As Object, e As System.EventArg s)
VisibleForm(fal se)
RaiseEvent CancelClick()
End Sub

Sub VisibleForm(bln Form as Boolean)
lblAmount.visib le = blnForm
txtAmount.visib le = blnForm
btnReport.visib le = blnForm
btnCancel.visib le = blnForm
End Sub
End Class

</script>
<table>
<tr><td class="bodytext "><asp:labe l ID="lblAmount" runat="server"
Text="Amount:" /></td>
<td class="bodytext "><asp:text box runat="server" ID="txtAmount"
/></td></tr>
<tr><td class="bodytext "><asp:butt on ID="btnReport" runat="server"
Text="Submit Report" CssClass="btnCl ass" /></td><td
class="bodytext "><asp:butt on ID="btnCancel" runat="server" Text="Cancel"
CssClass="btnCl ass" OnClick="Cancel Report" /></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
4139
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 of the tabs has a subform showing order data (in datasheet view). On the same tab there is an unbound textbox (next to the datasheet). I placed a
8
1609
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 that acts on all these textboxes. Therefore I would like to refer to these textboxes as an array.
1
2075
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"; and another variable: $name = "Epson"; Then you can refer to $name, or $$var. They will equal the same thing.
4
2917
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 some textboxes not updating when i a hit save. for example I have this code in my aspx.cs file: declared:
4
1692
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
1329
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 child form is opened inside the container form "frmChild" which displays a datagrid. The WHERE clause in the select statement which is bound to the grid comes from the textbox on the Parent form. How do I refer to this textbox control ?
2
19857
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
8332
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 = txt(x).text next x
0
2397
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 View I want the form populated from there profile on the sql server. The code to save the profile works fine. But when the user logs back in they data doesn't load back to the form. The multiview is located inside the LoginView's Logged-In View ....
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7738
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.