473,668 Members | 2,661 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1417
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.vad ivelk.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 CreateChildCont rols()
'Set some properties of the controls
ddl.Items.Add(" One")
ddl.Items.Add(" Two")
ddl.Items.Add(" Three")
ddl.Items.Add(" Four")
ddl.AutoPostBac k = 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.SelectedInd exChanged, AddressOf
ddl_SelectedInd exChanged
End Sub

Private Sub ddl_SelectedInd exChanged( _
ByVal sender As Object, ByVal e As EventArgs)
Me.EnsureChildC ontrols()
box1.Text = "You chose " & ddl.SelectedIte m.Text
End Sub

I have this in the html of the page:

<%@ Register TagPrefix="cc1" Namespace="Comp ositeControl"
Assembly="Compo siteControl" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1 </title>
<meta name="GENERATOR " content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post" action="WebForm 1.aspx" runat="server">
<cc1:WebCustomC ontrol1 id="WebCustomCo ntrol11"
runat="server" Text="Choose a number:"></cc1:WebCustomCo ntrol1>
</form>
</body>
</HTML>
Notice anything which might be causing the problem?

Jul 20 '06 #3


Found the problem: I wasn't implementing INamingContaine r 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
6924
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 StudentID)? I enventually will convert the Access db to an SQL db. I've always used single primary keys based on long integers, usually autonumbered.
18
12646
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 relations with the table containing no primary key. Do I just create two primary keys on the table that does not contain any primary key for this to become a composite primary key? Thank you in advance! Still a newbie,
0
1585
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 control should display 2 columns and 2 rows per page. I am able to display 4 Composite Controls independently, when the user is changing the index of the DropDownList control, automatcially the output should get reflected on the composite control...
1
2064
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 application immediately hangs! Spy++ indicates that the application is hanging on the WM_GETDLGCODE message. This problem does not happen if the ATL control is a standard (that is, non-composite) control, neither does it happen if the composite...
0
1625
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 control is a date picker which contains a couple of basic text, drop down and image button controls. My control follows the composite design guidelines carefully and behaves perfectly when used on a web page. It uses ViewState and gets events from is...
10
2310
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 controls that I don't understand... I've included a snippet from Chapter 12 below on Composite Controls: <start> Override the CreateChildControls method to instantiate child controls, initialize them, and add them to the control tree. Do not perform...
3
3002
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 lifecycle of a page with a custom composite control on it. You can find that document here: http://www.ats-engineers.com/lifecycle.htm
3
1942
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 Label and the TextBox are each rendered in one of the cells. Everything renders fine. The problem is that depending on the column the control represents I may want the textbox to be a different visible size during both design and runtime. I...
6
2621
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 control implement INamingContainer? In this moment I am working on a custom control that is composed by a
0
8462
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
8797
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...
1
8583
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
7401
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6209
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5681
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
4205
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
2791
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
1786
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.