473,797 Members | 3,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 AccountCenterGe neral
Inherits System.Web.UI.U serControl

#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub InitializeCompo nent()
End Sub

Protected Shared WithEvents txtSalesTaxPerc ent As
System.Web.UI.W ebControls.Text Box
Protected WithEvents txtNotes As System.Web.UI.W ebControls.Text Box
#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 = AccountCenterGe neral.Notes (AccountCenterG eneral 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.FindContro l("AccountCente rGeneral1").Fin dControl("txtIn terestRate")
tempString = currentTextBox. Text

Thanks in advance! Brian



Apr 24 '06 #1
0 1159

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

Similar topics

11
1686
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 beyond frustration. It seems that with every new VS release the documentation falls further behind. What I want to do should be simple but I can find no way to do it with VS with any visual designer support. I thought the 'V' in VS stood for...
6
402
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 Variable name of "Public string Fred" in the control, will the page that uses the control be able to see this global variable or is there something that I need to do to make it available to the page which uses the control Thanks in advance for your...
1
1022
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 variable (targetId) in to the usercontrol (IntergySite.aspx) by calling its setter method. Currently, I am using if-then-else and hardcoded the User Control Object to do casting and call the setter method. Question: Is there any way I could load,...
8
1501
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 HELP ME.
0
1173
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 with the user control, I can click on links, buttons etc on the user control and navigate around. On subsequent postbacks, say when a user submits a new query, the buttons and links on the user control are "un-clickable". You get no click sound...
0
978
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 page of the 'main' web page. I have done this so far...
1
1823
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 control with a list of folders (let's call it the TREE) 2) There is another control called document list which shows the list of documents for the selected tree folder (let's call it DOCLIST)
9
3194
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 load with different data (locations, departments, etc.).
4
2497
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 unsuccessfully in creating the whole pane as a user control and have succeeded in adding the pane and then dynamically adding the content which is a user control to the pane, dynamically within the page. However I would like to have a single pane...
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9536
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
10468
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
10245
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...
0
6802
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5458
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4131
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
3748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2933
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.