T
Tony!
With the code below, if I click RadioButton1, It shows the two images,
one on top of the other.
If I take the 2nd image code out of the RadioButton1's event and put
the code for the 2nd image into it's own option button ( RadioButton2)
code, the image then replaces the previous image instead of 'adding"
I'm guessing it has to do with scope, but how would I keep adding to
the placeholder.controls in code?
(This is a bad example, I know, my plan is to use checkboxes instead
of radiobuttons, but I'm just testing/learning at the moment with this
code)
In my. aspx file:
<td valign="top" width="50%">
<asplaceHolder ID="PlaceHolder1"
runat="server"></asplaceHolder>
</td>
in my .cs file:
protected void RadioButton1_CheckedChanged(object sender,
EventArgs e)
{
System.Web.UI.WebControls.Image img1; //Image
img1 = new System.Web.UI.WebControls.Image();
img1.ImageUrl = "~/Images/Pic1.png";
img1.ID = "img1";
img1.ToolTip = "This is an image";
//To set height and width of image
img1.Height = Unit.Pixel(110);
img1.Width = Unit.Pixel(1024);
PlaceHolder1.Controls.Add(img1);
System.Web.UI.WebControls.Image img2; //Image
img2 = new System.Web.UI.WebControls.Image();
img2.ImageUrl = "~/Images/Pic2.png";
img2.ID = "img2";
img2.ToolTip = "This is an image";
//To set height and width of image
img2.Height = Unit.Pixel(110);
img2.Width = Unit.Pixel(1024);
PlaceHolder1.Controls.Add(img2);
}
Any suggestions welcome
Thanks,
Tony!
one on top of the other.
If I take the 2nd image code out of the RadioButton1's event and put
the code for the 2nd image into it's own option button ( RadioButton2)
code, the image then replaces the previous image instead of 'adding"
I'm guessing it has to do with scope, but how would I keep adding to
the placeholder.controls in code?
(This is a bad example, I know, my plan is to use checkboxes instead
of radiobuttons, but I'm just testing/learning at the moment with this
code)
In my. aspx file:
<td valign="top" width="50%">
<asplaceHolder ID="PlaceHolder1"
runat="server"></asplaceHolder>
</td>
in my .cs file:
protected void RadioButton1_CheckedChanged(object sender,
EventArgs e)
{
System.Web.UI.WebControls.Image img1; //Image
img1 = new System.Web.UI.WebControls.Image();
img1.ImageUrl = "~/Images/Pic1.png";
img1.ID = "img1";
img1.ToolTip = "This is an image";
//To set height and width of image
img1.Height = Unit.Pixel(110);
img1.Width = Unit.Pixel(1024);
PlaceHolder1.Controls.Add(img1);
System.Web.UI.WebControls.Image img2; //Image
img2 = new System.Web.UI.WebControls.Image();
img2.ImageUrl = "~/Images/Pic2.png";
img2.ID = "img2";
img2.ToolTip = "This is an image";
//To set height and width of image
img2.Height = Unit.Pixel(110);
img2.Width = Unit.Pixel(1024);
PlaceHolder1.Controls.Add(img2);
}
Any suggestions welcome
Thanks,
Tony!