and the image is not shown. if i check this with firebug, this line is inside div tag. but if i copy-paste this line into html, the image is shown. so, i'm doing somethin wrong, but don't know what.
The reason why the code doesn't work is that ASP. Net control is't parsed as HTML control. In order to resolve your issue, you can try to modify your code as follows:
string s = string.Format("<img src=\"~/ShowPictures.ashx?id={0}\" id=\"Image1\" runat=\"server\" style=\"height:200px;\"/>", "9b1feefd-3628-42e5-b3fa-82edb11f23f5");
Best wishes,
Please mark the replies as answers if they help or unmark if not.
Feedback to us
pacoss
Member
1 Points
25 Posts
cannot dynamically create images
Dec 14, 2012 01:22 PM|LINK
i'm trying to create images in runtime but something is wrong. here is html code:
<div id="thumbsContainer" runat="server"></div>
and c#:
protected void Page_Load(object sender, EventArgs e)
{
thumbsContainer.InnerHtml = GetImages();
}
protected string GetImages()
{
string s = string.Format("<asp:Image ImageUrl=\"~/ShowPictures.ashx?id={0}\" runat=\"server\" Height=\"200\" />", "9b1feefd-3628-42e5-b3fa-82edb11f23f5");
return s;
}
GetImages() produces:
<asp:image ID="Image1" height="200" runat="server" imageurl="~/ShowPictures.ashx?id=9b1feefd-3628-42e5-b3fa-82edb11f23f5"></asp:image>
and the image is not shown. if i check this with firebug, this line is inside div tag. but if i copy-paste this line into html, the image is shown. so, i'm doing somethin wrong, but don't know what.
please, any help ...
oned_gk
All-Star
31017 Points
6352 Posts
Re: cannot dynamically create images
Dec 14, 2012 01:39 PM|LINK
pacoss
Member
1 Points
25 Posts
Re: cannot dynamically create images
Dec 14, 2012 02:38 PM|LINK
this cannot be written this way, it produces error because of double quotes inside double quotes:
...string.Format("<asp:Image ImageUrl="~/ShowPictures ...
Catherine Sh...
All-Star
23373 Points
2490 Posts
Microsoft
Re: cannot dynamically create images
Dec 20, 2012 06:24 AM|LINK
Hi,
The reason why the code doesn't work is that ASP. Net control is't parsed as HTML control. In order to resolve your issue, you can try to modify your code as follows:
string s = string.Format("<img src=\"~/ShowPictures.ashx?id={0}\" id=\"Image1\" runat=\"server\" style=\"height:200px;\"/>", "9b1feefd-3628-42e5-b3fa-82edb11f23f5");Best wishes,
Feedback to us
Develop and promote your apps in Windows Store
sameer_khanj...
Contributor
7046 Points
1376 Posts
Re: cannot dynamically create images
Dec 20, 2012 06:34 AM|LINK
string s = string.Format("<img src='~/ShowPictures.ashx?id={0}' height='200' />", "9b1feefd-3628-42e5- b3fa-82edb11f23f5");sameer.khanjit@gmail.com
View Blog
Click "Mark as Answer" on the post that helped you.
manjuby
Participant
1131 Points
251 Posts
Re: cannot dynamically create images
Dec 20, 2012 06:36 AM|LINK
hERE IS THE FOR CONVERTING IMAGES TO DIFFERENT SIZE ...SAY THUMB IMAGES...
USE IT TO MEET UR OWN NEEDS
System.Drawing.Image.GetThumbnailImageAbort thumbnailImageAbortDelegate = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
if (FileUpload1.HasFile)
{
//FileUpload1.SaveAs(System.IO.Path.Combine(imagepath, FileUpload1.FileName));
using (System.Drawing.Bitmap originalImage = new System.Drawing.Bitmap(FileUpload1.PostedFile.InputStream))
{
using (System.Drawing.Image thumbnail = originalImage.GetThumbnailImage(80, 80, thumbnailImageAbortDelegate, IntPtr.Zero))
{
thumbnail.Save(Server.MapPath("~/ApplicationImages/" + "thumb_" + txtslno.Text + FileUpload1.FileName));
}
}
}
public bool ThumbnailCallback()
{
return false;
}