Peter here and I’m extra new to coding. What I’m attempting to do is check the actual image url and based on that, change the class. My current code is as so:
DataSet ds = cbb.getBannerModule(Convert.ToInt32(MyBannerID));
ImageButton ib = new ImageButton();
ib.ImageUrl = ds.Tables[0].Rows[0]["Banner_path"].ToString();
string URL = ib.ImageUrl;
ib.Width = Unit.Pixel(Convert.ToInt32(ds.Tables[0].Rows[0]["Banner_width"].ToString()));
ib.Height = Unit.Pixel(Convert.ToInt32(ds.Tables[0].Rows[0]["Banner_hight"].ToString()));
ib.PostBackUrl = ds.Tables[0].Rows[0]["Banner_link"].ToString();
string img1 = "~/admin/IMAGE/Banner/1.jpg";
string img2 = "~/admin/IMAGE/Banner/2.jpg";
string img3 = "~/admin/IMAGE/Banner/3.jpg";
if (URL == img1)
{
ban1.Attributes["class"] = "add 1";
}
else if (URL == img2)
{
ban1.Attributes["class"] = "add 2";
}
else if (URL == img3)
{
ban1.Attributes["class"] = "add 3";
}
else
{
ban1.Attributes["class"] = "add 4";
}
ban1.Controls.Add(ib);
The goal? Change the class to attempt and set a new picture for the hover feature. This is a system created by an outside vendor and the id and class are set inside the ascx file. They set it class=”add” but I want to add another class so that when you rollover the image it changes the image. Is that possible?
Classes name need to be in a single word. You cannot have “add 1” as a single name. Space is to separate multiple class for a single Dom object.
If you want, you can change too “add1” instead of “add 1” and so on. This will set the class to your image to “add1” instead of “add” and “1”.