大家好我使用下面的代碼添加圖像到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