Ask a Question related to ASP.NET, Design and Development.
-
Oliver Degnan #1
How to use embedded image in ASP.NET Server Control
I have a server control, written in ASP.NET, where I added two images
as "Embedded Resource" to it.
Now, I need to find a way to read the resource and produce an output
stream to have the image be displayed on the web page as a regular
image HTML tag such as "<img src='myResourceImage.gif'>".
Any help is greatly appreciated.
Thanks in advanvce.
Oliver
Oliver Degnan Guest
-
Custom Server Control Embedded in a DataGrid Event problem
Hi All, I have successfully created a Custom Server Control which is a Table that has an ImageButton in one of it's cells. When I use this... -
Databind an embedded control in an embedded datagrid
All, I have something like the following: Datagrid1 Col1 - bound column Col2 - template column Datagrid1_OnItemDataBound datagrid2 -... -
Can a URL be embedded in an image itself?
ImageReady documentation seems to indicatate that a URL can be assigned to an image, but it only seems to work if one also exports the HTML code with... -
what format is an embedded image
No info for embedded object in AI10 either, guys. -
Page Load fired 3 times Web user control is embedded in a custom control
Hi, I have built a custom control that build a table with 3 cells in it. The custom control is designed to add all child controls to cell#2,... -
Teemu Keiski #2
Re: How to use embedded image in ASP.NET Server Control
Hi,
to serve the image, you need to have custom Httphandler that would get it
from the resource files (image is separate resource from HTML itself, so it
needs to be requested separately). Anyway, you'd get the resource by using
Assembly.GetManifestResourceStream.
For example Andy Smith has following code in his FirstFocus control to get
embedded js file:
using (System.IO.StreamReader reader = new
System.IO.StreamReader(typeof(FirstFocus).Assembly .GetManifestResourceStream(typeof(FirstFocus),
"FirstFocusScript.js"))) {
String script = "<script language='javascript' type='text/javascript'this.Page.RegisterClientScriptBlock(pageScriptName , script);>\r\n<!--\r\n" + reader.ReadToEnd() + "\r\n//-->\r\n</script>";
}
Because you have image, you of course read it as stream, not as text.
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"Oliver Degnan" <odegnan@dmghost.com> wrote in message
news:e6c0b57d.0402121242.49bd20fa@posting.google.c om...
I have a server control, written in ASP.NET, where I added two images
as "Embedded Resource" to it.
Now, I need to find a way to read the resource and produce an output
stream to have the image be displayed on the web page as a regular
image HTML tag such as "<img src='myResourceImage.gif'>".
Any help is greatly appreciated.
Thanks in advanvce.
Oliver
Teemu Keiski Guest
-
Oliver Degnan #3
Re: How to use embedded image in ASP.NET Server Control
Thank you very much. I was able to acomplish the task with:
hc.Response.ContentType = "image/" + strType;
asm = Assembly.GetExecutingAssembly();
ReadBinaryResource(asm.GetManifestResourceStream(
cImageResPath + strResName), out byImage, out nLen);
hc.Response.OutputStream.Write(byImage, 0, nLen);
Oliver
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Oliver Degnan Guest



Reply With Quote

