大家好我使用下面的代码添加图像到label
文本图像的宽度是否有可能设置高度和被分配到一个标签动态
lblPopUp.Text = "<img src='Popup(Images)/notfound.png' /> Access Denied,Contact Administrator";
这导致了我如下的时候加载
是否有可能改变一些如下,这样的文字和图像看起来应该类似于什么
大家好我使用下面的代码添加图像到label
文本图像的宽度是否有可能设置高度和被分配到一个标签动态
lblPopUp.Text = "<img src='Popup(Images)/notfound.png' /> Access Denied,Contact Administrator";
这导致了我如下的时候加载
是否有可能改变一些如下,这样的文字和图像看起来应该类似于什么
如果我正确地理解了你,一个小小的字符串操作应该能够实现你想要的。
代码:
lblPopup.Text = "<img src='Popup(Images)/notfound.png' /> Access Denied,Contact Administrator";
String strInsertStyle = " style=\"height: 100px; width: 100px;\"";
int intInsertPoint = lblPopup.Text.IndexOf("<img") + 4;
lblPopup.Text = lblPopup.Text.Substring(0, intInsertPoint) + strInsertStyle + lblPopup.Text.Substring(intInsertPoint);
编辑: 我也假设你的意思是你想在以后添加的高度/宽度,与jadarnel27的答案,否则去。
您可以设置高度和宽度与<img>
标签的height
和width
属性:
lblPopUp.Text = "<img src='Popup(Images)/notfound.png' height='50px' width='50px' /> Access Denied,Contact Administrator";
或者,你可以使用style
属性:
lblPopUp.Text = "<img src='Popup(Images)/notfound.png' style='height:50px; width:50px;' /> Access Denied,Contact Administrator";
 
来确保您的对齐方式正确。在您的
<img>
标签上放置一些
padding-right
将会更容易和更稳定。
为jquery的缺席事先道歉;-) – jadarnel27 2012-02-02 16:39:50