473,385 Members | 1,409 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,385 software developers and data experts.

composite control problems

I have created a composite control in C# which shows a DropDownList with 4
items and when one is selected a relevant message appears in a TextBox. This
works fine.

I then tried to recreate the control using VB.NET, but when I select an item
from the list it posts back to the server and resets the list to the default
value. Nothing appears in the TextBox. AutoeventWireUp is set to false in
both projects, AutoPostBack for the DropDownList is set to true in the
control and I am using the same html to register the control.

Does anyone know of any issues when using different languages to create
composite controls?
Jul 20 '06 #1
3 1404
The problem seems to be doesn't connected with language issue. It could
be the reason that your ViewState doesn't seems to be maintaining the
values of the control. Did you tried to set True for EnableViewState
property of the controls.

Check for whether the ViewState is set to false in the page where you
are using the composite control.

If you still find problem, please put some of your source code here so
that we can check it.

--
Vadivel Kumar
http://www.vadivelk.net
va**@online.vadivelk.net (remove "online.")

cashdeskmac wrote:
I have created a composite control in C# which shows a DropDownList with 4
items and when one is selected a relevant message appears in a TextBox. This
works fine.

I then tried to recreate the control using VB.NET, but when I select an item
from the list it posts back to the server and resets the list to the default
value. Nothing appears in the TextBox. AutoeventWireUp is set to false in
both projects, AutoPostBack for the DropDownList is set to true in the
control and I am using the same html to register the control.

Does anyone know of any issues when using different languages to create
composite controls?
Jul 20 '06 #2
Hi Vadival,

here is the code to create the control:

Private box1 As New TextBox
Private WithEvents ddl As New DropDownList
Private lbl As New Label

Protected Overrides Sub CreateChildControls()
'Set some properties of the controls
ddl.Items.Add("One")
ddl.Items.Add("Two")
ddl.Items.Add("Three")
ddl.Items.Add("Four")
ddl.AutoPostBack = True
lbl.Text = Me.Text
'Add these controls to the controls collection
Me.Controls.Add(lbl)
'This gives us a new line
Me.Controls.Add(New LiteralControl("<br>"))
Me.Controls.Add(ddl)
Me.Controls.Add(New LiteralControl("<br><br>"))
Me.Controls.Add(box1)
AddHandler ddl.SelectedIndexChanged, AddressOf
ddl_SelectedIndexChanged
End Sub

Private Sub ddl_SelectedIndexChanged( _
ByVal sender As Object, ByVal e As EventArgs)
Me.EnsureChildControls()
box1.Text = "You chose " & ddl.SelectedItem.Text
End Sub

I have this in the html of the page:

<%@ Register TagPrefix="cc1" Namespace="CompositeControl"
Assembly="CompositeControl" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" action="WebForm1.aspx" runat="server">
<cc1:WebCustomControl1 id="WebCustomControl11"
runat="server" Text="Choose a number:"></cc1:WebCustomControl1>
</form>
</body>
</HTML>
Notice anything which might be causing the problem?

Jul 20 '06 #3


Found the problem: I wasn't implementing INamingContainer in the control.

Sorted now.
Jul 20 '06 #4

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

Similar topics

5
by: John | last post by:
Specifically for joint tables... tblStudents tblClasses tblClasses_Students Is it be good programming to use a composite primary key in tblClasses_Students (where the key is ClassID and...
18
by: Thomas A. Anderson | last post by:
I am a bit confused in creating a composite primary key. I have three table with two of the tables containing primary keys. I have two of the tables (each with a primary key) having one to many...
0
by: Satya Bojanapally | last post by:
Hi, I am unable to add a pager for this composite control. I had created a composite control in C#. The control is having 5 labels, one radio button and one DropDownList control. The composite...
1
by: Paul Kia | last post by:
I have an ATL composite control which I drop into a tab control dialog page of an MFC application. When I click on the composite control and then click anywhere outside the MFC application, the...
0
by: Phil S. | last post by:
I'm having dreadful trouble putting a simple composite control into the DataGrid cell, so I'm hoping someone might have stumbled across this problem before and have some advice. My composite...
10
by: dx | last post by:
I have the Microsoft Press: Developing Microsoft ASP.NET Server Controls and Components book. It's starting to shine some light on control development but there is something about composite...
3
by: Beavis | last post by:
I hate to repost a message, but I am still at the same point where I was when I originally posted, and hopefully someone else will see this one... Ok, so I have gone off and documented the...
3
by: Eric | last post by:
I have created a fairly basic composite control consisting of a Label and a TextBox. In the overridden Render function, I'm creating a table with two rows and each row contains a cell (td). The...
6
by: shapper | last post by:
Hello, I am working in a class library with various custom controls. In which cases should a control inherit Control, WebControl and CompositeControl classes? And when should a custom...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.