473,405 Members | 2,185 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,405 software developers and data experts.

UserControl Property Problem: Need help

I have a UserControl with a TextBox "TextBox_1" and a ReadOnly Property "myText" in it. I am using this in a file (no Code Behind) as follows :
HTML:
<My:Control ID="txtName" runat="server" />
VB:
Dim var_1 as String = txtName.myText
Till here everything works fine.

Now I am trying to convert my file to a Code Behind file and here starts my problem.
<My:Control ID="txtName" runat="server" /> is in WebForm1.aspx now and
Dim var_1 as String = txtName.myText is in WebForm1.aspx.vb.
During the compilation it says "txtName is not declared", which I understand because I cannot declare it using the similar command as follows:
Protected txtNotes As System.Web.UI.WebControls.TextBox

So my question is how should I declare "txtName" to use it in a CodeBehind ?
I read a lot in MSDN but could not find the answer.

Thanks in advance
Raja

Nov 18 '05 #1
1 989
Raja,

If you put the following line of code into your
WebForm1.aspx.vb file:

Protected WithEvents txtName as UserControl1

(put the actual class name instead of UserControl1) - then
you should be able to compile and use your control in code.

Hope this helps.

Sergey
-----Original Message-----
I have a UserControl with a TextBox "TextBox_1" and a ReadOnly Property "myText" in it. I am using this in a
file (no Code Behind) as follows :HTML:
<My:Control ID="txtName" runat="server" />
VB:
Dim var_1 as String = txtName.myText
Till here everything works fine.

Now I am trying to convert my file to a Code Behind file and here starts my problem.<My:Control ID="txtName" runat="server" /> is in WebForm1.aspx now andDim var_1 as String = txtName.myText is in WebForm1.aspx.vb.During the compilation it says "txtName is not declared", which I understand because I cannot declare it using the
similar command as follows: Protected txtNotes As System.Web.UI.WebControls.TextBox
So my question is how should I declare "txtName" to use it in a CodeBehind ?I read a lot in MSDN but could not find the answer.

Thanks in advance
Raja

Nov 18 '05 #2

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

Similar topics

4
by: DraguVaso | last post by:
Hi, I'm having some weird behaviour, and I can't find any solution to this. I made a UserControl (uclCommands) which contains a Toolbar (ToolBar1) with Modifiers = Public. I put this...
2
by: bill yeager | last post by:
When trying to run my web project, I get the following error: Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the...
2
by: Lau Lei Cheong | last post by:
Hello, I'm writing a usercontrol that contains a property named "disabled". It is set to false by default but there is also another button in the usercontrol that'll set it to true. On the...
2
by: Benedict Teoh | last post by:
I created a dropdownlist containing day, month and year field and expose a property to assign a date. When I call from a aspx page and assign the value, the new date is not displayed until a submit...
1
by: Kepler | last post by:
I have a custom control that is thrown onto a UserControl that is thrown onto a WebForm. Basically, I've got a scenario where if my UserControl sets an attribute on the custom control in the ascx,...
21
by: Simon Verona | last post by:
Hope somebody can help! I want to automatically be able to add code to the initialize routine on a Windows form when I add a custom control that I've written to a form. Specifically, I'm trying...
1
by: Philipp Lenz | last post by:
I'm very confused about how this works, all the tutorials out there show me how to apply a skin to a webcontrol, but I want to know how I can access the components of a control....for example: I...
3
by: Jeff | last post by:
Hey ASP.NET 2.0 This the ObjectDataSource in my UserControl, <asp:ObjectDataSource ID="odsMessage" runat="server" SelectMethod="ExecuteMessage" TypeName="AH.MyNetwork.BLL.Network.Message">...
6
by: MeowCow | last post by:
I have created a UserControl that encapsulates a third party data grid. My goal was to create my own DataSource and DataMember properties that forward the binding to the third party grid, then use...
1
by: xke | last post by:
I have a base class which overrides CreateChildControls / Render. Inside CreateChildControls, based on a public property ShowLinks in this class, I can include/display a usercontrol (kind of set of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.