Reputation: 1138
I have a class which accesses the database to get an url of an image which is stored in the db. Then it displays the image to the user.
Here is my code behind class:
protected void Page_Load(object sender, EventArgs e)
{
string image;
Advertisement Ad= BusinessLogic.getAd(8);
image = Ad.getImage();
lblImage.Text = "<img alt='' src='image' />";
}
My problem is the image doesn't get displayed in the web form, but if i pass the url directly to the src it works perfectly. I can assure that the stored url link is correct and the url is return using Ad.getImage() method.
Directly passing example:
protected void Page_Load(object sender, EventArgs e)
{
string image;
Advertisement Ad= BusinessLogic.getAd(8);
image = Ad.getImage();
lblImage.Text = "<img alt='' src='http://o.aolcdn.com/hss/storage/adam/bfeae281284ba5cfd120f41e489eac23/honda-vezel.jpgimage' />"; //directly passed without accessing db
}
What can be the problem here?
Thank you for your time
Upvotes: 0
Views: 1676
Reputation: 10295
I think There may be a problem with URL or Better to use FireBug (Debugger Tool)
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string image;
Advertisement Ad= BusinessLogic.getAd(8);
image = Ad.getImage();
ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "alert('"+image+"');", true);
// it will alert image path
lblImage.Text = "<img alt='' src='"+image+"' />";
}
}
Upvotes: 2