我在我的web應用程序中顯示圖像時遇到問題。它從數據庫中獲取照片,並在Web應用程序中顯示。在web應用程序中顯示圖像
protected void btnShowPhoto_Click(object sender, EventArgs e)
{
string adresURL = @"~/Content";
string camPath = "";
string[] tab = new string[10];
CheckBox[] _boxes = new CheckBox[] { this.CheckBox1, this.CheckBox2, this.CheckBox3, this.CheckBox4, this.CheckBox5, this.CheckBox6, this.CheckBox7, this.CheckBox8 };
System.Web.UI.WebControls.Image[] _images = new System.Web.UI.WebControls.Image[] { this.Image1, this.Image2, this.Image3, this.Image4, this.Image5, this.Image6, this.Image7, this.Image8 };
Label[] _labels = new Label[] { this.lblCameraName1, this.lblCameraName2, this.lblCameraName3, this.lblCameraName4, this.lblCameraName5, this.lblCameraName6, this.lblCameraName7, this.lblCameraName8 };
System.Web.UI.HtmlControls.HtmlAnchor[] _linkscontrol = new System.Web.UI.HtmlControls.HtmlAnchor[] { this.imagelink1, this.imagelink2, this.imagelink3, this.imagelink4, this.imagelink5, this.imagelink6, this.imagelink7, this.imagelink8 };
for (int i = 0; i < 8; i++)
{
_images[i].Visible = false;
_labels[i].Visible = false;
_linkscontrol[i].HRef = "";
}
for (int i = 0; i < 8; i++)
{
if (_boxes[i].Checked)
{
camPath = null;
tab = null;
camPath = this.GridView2.Rows[i].Cells[0].Text;
tab = camPath.Split(new string[] { "StoredPhotos" }, StringSplitOptions.None);
//Virtual Path'a
camPath = adresURL + tab[1].Replace(@"\", "/");
_labels[i].Visible = true;
_labels[i].Text = this.GridView2.Rows[i].Cells[1].Text;
_linkscontrol[i].HRef = camPath;
_images[i].ImageUrl = camPath;
_images[i].Visible = true;
}
else
_images[i].Visible = false;
}
}
我的虛擬路徑可能有問題。 E::坎帕斯(虛擬路徑)距離變得\照片\ StoredPhotos \ 20151010 \ 000003819619_201512021335_1_C1,最後的樣子:〜/ 20151010/000003819619_201512021335_1_C1
@ 「/內容」 不工作.ImageUrl值..,ToAbsolute(CAMPATH) - 也。我會嘗試不同的方式。 TY。 – mistiq
@mistiq:你必須比「不工作」更具體。 *它做什麼*完全*它如何失敗? – David
好的。抱歉。這意味着,結果與以前相同,如上所示。 – mistiq