how to make two or more User Controls to interact with each other

T

triveni.chandran

I have two ascx files (header.ascx,footer.ascx) on default.aspx file.
In header.ascx file User Control hosts a DropDownList containing a list
of Colors. if any change event occurs in the dropdown list,it should
reflect in the footer.ascx file label.

please can any one tell me vb coding.
Thanks in Advance.
 
G

Guest

I don't think the goal is for the header and footer controls to communicate
with one another.

In your header create a public event, call it "ColorChanged" or whatever.
Also create a property called CurrentColor. Then on the default page add an
event handler to the ColorChanged event. When the SelectedIndexChanged event
fires for the droplist then set the CurrentColor property and fire your
ColorChanged event.

In the ColorChanged event handler get the CurrentColor and call a method on
the Footer control, call it ShowColor, and pass it the CurrentColor as a
parameter.
 
R

Richard Carpenter

On a related note, I was trying to change the background color of a
table cell (<td>) upon the click of a button, and the following code
wouldn't work:

TableCell.Background-color = "#990000";

I get an error to the effect of "Unable to implicitly convert string
value to type System.Color".

How do I go about assigning a color to an object in this manner?

Rich
 
N

neilmcguigan

there may be a simpler way to do this, but...

System.Drawing.ColorConverter cc = new
System.Drawing.ColorConverter();
System.Drawing.Color c = (System.Drawing.Color)
cc.ConvertFromString("#990000");

TableCell.BackColor = c;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top