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

  • Thread starter Thread starter triveni.chandran
  • Start date Start date
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.
 
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.
 
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
 
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;
 
Back
Top