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="ComboBox.ascx.vb" Inherits="globalDocWeb.ComboBoxUserControl"
TargetSchema="http://schemas.microsoft.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:dropdownlist visible=False id="cmbDdl" runat="server" >
</asp:dropdownlist><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 ComboBoxUserControl
Inherits System.Web.UI.UserControl
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
Protected WithEvents cmbDdl As System.Web.UI.WebControls.DropDownList
Protected WithEvents cmbTxt As System.Web.UI.WebControls.TextBox
Protected WithEvents btnDdl As System.Web.UI.WebControls.Button
Protected WithEvents btnTxt As System.Web.UI.WebControls.Button
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
InitializeComponent()
End Sub
Private Sub btnDdl_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnDdl.Click
cmbTxt.Visible = False
btnDdl.Visible = False
cmbDdl.Visible = True
btnTxt.Visible = True
End Sub
Private Sub btnTxt_Click(ByVal sender As Object, ByVal e As
System.EventArgs) 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 ComboBoxUserControl = CType(e.Item.FindControl("Name"),
ComboBoxUserControl) 2 2292
That is because everytime a postback is fired (the button is clicked) the
datalist will be rebuild and the command of the button will not be
identified as code of the newly created button.
--
Daniel Fisher(lennybacon)
MCP ASP.NET C#
Blog: http://www.lennybacon.com/
"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.
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="ComboBox.ascx.vb" Inherits="globalDocWeb.ComboBoxUserControl" TargetSchema="http://schemas.microsoft.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:dropdownlist visible=False id="cmbDdl" runat="server" > </asp:dropdownlist><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 ComboBoxUserControl Inherits System.Web.UI.UserControl
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub Protected WithEvents cmbDdl As System.Web.UI.WebControls.DropDownList Protected WithEvents cmbTxt As System.Web.UI.WebControls.TextBox Protected WithEvents btnDdl As System.Web.UI.WebControls.Button Protected WithEvents btnTxt As System.Web.UI.WebControls.Button
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init InitializeComponent() End Sub
Private Sub btnDdl_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDdl.Click cmbTxt.Visible = False btnDdl.Visible = False cmbDdl.Visible = True btnTxt.Visible = True End Sub
Private Sub btnTxt_Click(ByVal sender As Object, ByVal e As System.EventArgs) 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 ComboBoxUserControl = CType(e.Item.FindControl("Name"), ComboBoxUserControl)
Hi,
1. Give a command name to the button.
2. When the button is clicked, the textbox should not be visible.
Hope it helps.
Prakash.C
"Daniel Fisher(lennybacon)" wrote: That is because everytime a postback is fired (the button is clicked) the datalist will be rebuild and the command of the button will not be identified as code of the newly created button.
-- Daniel Fisher(lennybacon) MCP ASP.NET C# Blog: http://www.lennybacon.com/
"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.
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="ComboBox.ascx.vb" Inherits="globalDocWeb.ComboBoxUserControl" TargetSchema="http://schemas.microsoft.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:dropdownlist visible=False id="cmbDdl" runat="server" > </asp:dropdownlist><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 ComboBoxUserControl Inherits System.Web.UI.UserControl
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub Protected WithEvents cmbDdl As System.Web.UI.WebControls.DropDownList Protected WithEvents cmbTxt As System.Web.UI.WebControls.TextBox Protected WithEvents btnDdl As System.Web.UI.WebControls.Button Protected WithEvents btnTxt As System.Web.UI.WebControls.Button
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init InitializeComponent() End Sub
Private Sub btnDdl_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDdl.Click cmbTxt.Visible = False btnDdl.Visible = False cmbDdl.Visible = True btnTxt.Visible = True End Sub
Private Sub btnTxt_Click(ByVal sender As Object, ByVal e As System.EventArgs) 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 ComboBoxUserControl = CType(e.Item.FindControl("Name"), ComboBoxUserControl) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
by: Moojjoo |
last post by:
Ok fellow C# developers:
How do creat an instance of an object inside a dataset or datagrid.
Example I need to have a placeholder inside a dataset. Any help would be
great.
|
by: Scott Schluer |
last post by:
Hello,
I've got myself a small problem and I'm hoping someone can help.
I have a DataList called dlProducts (displays products from a database).
Within the <ItemTemplate> container of the...
|
by: V. Jenks |
last post by:
What seems like a simple thing is apparently not so
straightforward?
I have a datalist.
Inside of that datalist is an <itemtemplate> secion which
contains other server controls such as a...
|
by: Jack |
last post by:
Hi,
If I just say have a user control which contains a datalist that
displays information about different companies. The datalist contains
an image for the company logo and some text describing...
|
by: Scott McChesney |
last post by:
I have a problem I hope you folks can help me with.
I have an application that is using a tab-based interface, with the ability
for users to drag an item from a ListBox onto the tab control. ...
|
by: Charles Law |
last post by:
For some reason, when I click the X to close my MDI parent form, the action
appears to be re-directed to one of the MDI child forms, and the parent
remains open. I am then unable to close the...
|
by: Amil Hanish |
last post by:
I want to create a bunch of like user controls and display them in a
DataList.
Does anyone have a GOOD example of how to do this?
I thought I had it...I added the user control to my...
|
by: Seth Petry-Johnson |
last post by:
Is there a way to compile a user control into a redistributable
assembly , but still have access to its child
controls using the .Controls property?
Here's what I mean:
I have a user control...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |