即時讀取數據從XML。如何在asp.net中的代碼中添加href的高度和寬度?
{
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("~/multipleimage.xml"));
XmlNode root = doc.DocumentElement;
XmlNodeList nodeList = root.SelectNodes("Image");
foreach (XmlNode node in nodeList)
{
HtmlAnchor a1 = new HtmlAnchor();
Image imagesource = new Image();
string path = "Uploads/";
string imageurl = path + node.SelectSingleNode("Imagepath").InnerText;
imagesource.Style.Add(HtmlTextWriterStyle.PaddingLeft, "7px");
imagesource.Style.Add(HtmlTextWriterStyle.PaddingRight, "5px");
imagesource.Style.Add(HtmlTextWriterStyle.PaddingTop, "5px");
imagesource.Style.Add(HtmlTextWriterStyle.PaddingBottom, "5px");
imagesource.ImageUrl = imageurl;
imagesource.Height = 90;
imagesource.Width = 90;
string imagetitle = node.SelectSingleNode("imagetitle").InnerText;
a1.Attributes.Add("href", imageurl);
a1.Attributes.Add("rel", "lightbox[roadtrip]");
a1.Attributes.Add("title", imagetitle);
a1.Controls.Add(imagesource);
Div1.Controls.Add(a1);
}
}
所以即時通訊綁定在codebehind.i'm控件使用燈箱效果也在後面的代碼。一切工作正常。但我可以在後面的代碼設置高度和寬度的HREF?
爲什麼你不使用CSS來設計你的元素? – RePierre 2013-04-30 11:04:13