473,549 Members | 2,583 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

user control and setting properties of child controls

I have built a simple user control that contains 2 buttons, a text box and a
dropdownlist. When a button is clicked it sets the visible property
of the textbox/dropdownlist and the button. ie the buttons allow me to
toggle between the textbox and the dropdownlist. This works fine when the
control
is placed on the page but when it is placed inside a datalist, ie the
itemtemplate, the onclick events for the buttons fire but the visibility is
not set.

How do I change the visibility of the child controls of a user control when
it is placed inside a datalist?

I have placed some code below in the hope that it helps.Thanks in advance.
*************** this is my user control******** *************** *
<%@ Control Language="vb" AutoEventWireup ="false"
Codebehind="Com boBox.ascx.vb" Inherits="globa lDocWeb.ComboBo xUserControl"
TargetSchema="h ttp://schemas.microso ft.com/intellisense/ie5" %>
<nobr>
<asp:textbox id="cmbTxt" runat="server" ></asp:textbox>
<asp:button id="btnDdl" runat="server" Text="ddl"
Width="32px"></asp:button>
</nobr>

<nobr><asp:drop downlist visible=False id="cmbDdl" runat="server" >
</asp:dropdownlis t><asp:button visible=False id="btnTxt" runat="server"
Text="txt" Width="32px"></asp:button>
</nobr>

***********this is the code behind of the user
control******** *************** *****

Public Class ComboBoxUserCon trol
Inherits System.Web.UI.U serControl
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub
Protected WithEvents cmbDdl As System.Web.UI.W ebControls.Drop DownList
Protected WithEvents cmbTxt As System.Web.UI.W ebControls.Text Box
Protected WithEvents btnDdl As System.Web.UI.W ebControls.Butt on
Protected WithEvents btnTxt As System.Web.UI.W ebControls.Butt on

Private designerPlaceho lderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
InitializeCompo nent()
End Sub

Private Sub btnDdl_Click(By Val sender As Object, ByVal e As
System.EventArg s) Handles btnDdl.Click
cmbTxt.Visible = False
btnDdl.Visible = False
cmbDdl.Visible = True
btnTxt.Visible = True
End Sub

Private Sub btnTxt_Click(By Val sender As Object, ByVal e As
System.EventArg s) Handles btnTxt.Click
cmbTxt.Visible = True
btnDdl.Visible = True
cmbDdl.Visible = False
btnTxt.Visible = False
End Sub
End Class

*********this is how I access the control within the itemdatabound event of
the datalist*******

Dim list As ComboBoxUserCon trol = CType(e.Item.Fi ndControl("Name "),
ComboBoxUserCon trol)
Jul 21 '05 #1
1 2057
"Roman" <sp**@spam.de > wrote in message news:cr******** **@online.de...
I have built a simple user control that contains 2 buttons, a text box and
a dropdownlist. When a button is clicked it sets the visible property
of the textbox/dropdownlist and the button. ie the buttons allow me to
toggle between the textbox and the dropdownlist. This works fine when the
control
is placed on the page but when it is placed inside a datalist, ie the
itemtemplate, the onclick events for the buttons fire but the visibility
is not set.


Haven't I seen this post before? Please don't cross-post.

John Saunders
Jul 21 '05 #2

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

Similar topics

11
1675
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...
4
270
by: Mark Goldin | last post by:
I'd like to create a user control (Label and Text box) and modify every instance of that control when I add it to a web page. How can I do that?
1
319
by: Roman | last post by:
I have built a simple user control that contains 2 buttons, a text box and a dropdownlist. When a button is clicked it sets the visible property of the textbox/dropdownlist and the button. ie the buttons allow me to toggle between the textbox and the dropdownlist. This works fine when the control is placed on the page but when it is placed...
2
4904
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is being updated by some other process through remoting. When the page loads, I init the tree, and in my browser I can see the initialized tree. The...
0
3242
by: Jeremy Chapman | last post by:
I have included below virtually all the code to a control I'm trying to build. My issue is that an array list property in my control does not get persisted properly to the aspx page code in design time. If I type the code in the aspx manually it does get parsed correctly though. This is an example of the aspx code that gets parsed...
3
3902
by: Mark Rae | last post by:
Hi, Just a general quickie on setting properties of user controls from the parent form. Let's say I have a user control called note.ascx which displays a datagrid. That datagrid is populated according to an integer variable in the ViewState of the parent form. The code behind (still in v1.1) of the user control contains the following:
9
2592
by: abprules | last post by:
Can somehow tell me the best way for multi user development to occur in MS Access? The situation is: We are creating a new database for a small company. There are 2 of us who want to simultaneously work on development. Does splitting the database and creating FE's work for this scenario? And if so, would the changes that both users make be...
6
11060
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to how those properties are set. I want to be able to do two other things: a) add User control instances to my page, filling in the place of...
1
1364
by: tshad | last post by:
I have a User control that has some asp:textboxes and asp:labels in it where I want to change the visibility and forecolor of these controls. Right now I am getting and setting the .net controls using properties: *************************************** Public Property FullName AS String Get Return objFullName.Text End Get Set
0
7527
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...
0
7726
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. ...
0
7967
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...
1
7485
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7819
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5097
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...
0
3505
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...
0
3488
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
772
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...

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.