471,078 Members | 811 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,078 software developers and data experts.

User Control question

I am using framework 1.1

I have a user control and a web page.

I want to set up properties on the user control, so I can access the text
boxes on the user control when I am in the code behind page of the 'main'
web page.

I have done this so far...
1) On the user control... in the #Region " Web Form Designer Generated Code
" I have 2 text boxes (for simplicity of this question). If I am on the
main web page and I want to access the text boxes on the user control, I
have to change the defenition of the text box from Protected WithEvents to
Protected Shared WithEvents. Then I create the property like this in the
user control...

Public Class AccountCenterGeneral
Inherits System.Web.UI.UserControl

#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub

Protected Shared WithEvents txtSalesTaxPercent As
Protected WithEvents txtNotes As System.Web.UI.WebControls.TextBox
#End Region

Public Property Notes() As String
Return txtNotes.Text
End Get

Set(ByVal Value As String)
txtNotes.Text = Value
End Set
End Property

2) In the main web page, I can then code this to access the text box

dim tempString as string
tempString = AccountCenterGeneral.Notes (AccountCenterGeneral is the
name of my class in the user control)

THE PROBLEM... often times, if I make a change to the user control, ALL of
my definitions for the controls get changed back to Protected WithEvents
automatically and I have to reset them to Protected Shared WithEvents. So
I'm wondering if I am doing this all wrong, or if I should go back to using
this type of code... (can anyone explain which way is better)?

dim tempString as string
Dim currentTextBox As TextBox
currentTextBox =
Page.FindControl("AccountCenterGeneral1").FindCont rol("txtInterestRate")
tempString = currentTextBox.Text

Thanks in advance! Brian

Apr 24 '06 #1
0 1059

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Lloyd Sheen | last post: by
6 posts views Thread by Jim Heavey | last post: by
8 posts views Thread by Prince Mathew | last post: by
reply views Thread by campwes | last post: by
reply views Thread by Brian Cesafsky | last post: by
1 post views Thread by weboweb | last post: by
4 posts views Thread by =?Utf-8?B?UmljaEI=?= | last post: by
reply views Thread by leo001 | last post: by

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.