473,323 Members | 1,551 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,323 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
System.Web.UI.WebControls.TextBox
Protected WithEvents txtNotes As System.Web.UI.WebControls.TextBox
#End Region

Public Property Notes() As String
Get
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 1132

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

Similar topics

11
by: Lloyd Sheen | last post by:
Is there any one who has actually done this. I have now scanned more web articles about this with the realization that not one of them (including MSDN docs) outlines how to do this. This is...
6
by: Jim Heavey | last post by:
Hello, I have a user control which I place at the top of each page. I want to have code in this user control which sets the value of a couple of module variables and I was wondering if I create a...
1
by: Reza Nabi | last post by:
Bakground: I have a webform (LoadCtl.aspx) which loads the user control to a placeholder dynamically based on the ctlName querystring passed in the URL. Webform (LoadCtl.aspx) also passes a...
8
by: Prince Mathew | last post by:
Hi All, I have a requirement. I am throwing an exception from my user control I want to catch this in my container page. Is this possible? I don't want any event to be raised. PLEASE...
0
by: campwes | last post by:
Hey there. I have a user control on an aspx page that displays data based on a query (handled by another user control also on the page). I've noticed that the first time I navigate to the page...
0
by: Brian Cesafsky | last post by:
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...
1
by: weboweb | last post by:
Hello aspnet experts! I have a design question for the more experienced developers (more than me at least :-)). 1) I have a page in the application I'm building that displays a web user...
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.