How to refer to textbox in class?

J

John Mason

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.
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top