Showing posts with label image. Show all posts
Showing posts with label image. Show all posts

Thursday, March 29, 2012

HTML IMG vs ASP:IMAGE performance

I have no need to have server control over an image.
What is the best choice to use HTML img tag or asp:image for best
performance?
thanks,
Goncalo BoleoHTML controls provide slightly better performance than Web Controls, so go
with the img tag.
Here's more info:
http://SteveOrr.net/faq/3in1.aspx#HTMLvsWeb
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Gonalo Bolo" <gboleo@.netcabo.pt> wrote in message
news:el6Fu7PRFHA.356@.TK2MSFTNGP14.phx.gbl...
>I have no need to have server control over an image.
> What is the best choice to use HTML img tag or asp:image for best
> performance?
> thanks,
> Goncalo Boleo
>
If there's no need to have a server control, then just use a <img> tag (prim
arily
for simplicity, even though it is faster but it's negligible). If you are
using a server control there's essentially no difference between the HtmlCon
trols
and the WebContorls.
-Brock
DevelopMentor
http://staff.develop.com/ballen

> I have no need to have server control over an image.
> What is the best choice to use HTML img tag or asp:image for best
> performance?
> thanks,
> Goncalo Boleo

HTML IMG vs ASP:IMAGE performance

I have no need to have server control over an image.
What is the best choice to use HTML img tag or asp:image for best
performance?

thanks,
Goncalo BoleoHTML controls provide slightly better performance than Web Controls, so go
with the img tag.

Here's more info:
http://SteveOrr.net/faq/3in1.aspx#HTMLvsWeb

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Gonalo Bolo" <gboleo@.netcabo.pt> wrote in message
news:el6Fu7PRFHA.356@.TK2MSFTNGP14.phx.gbl...
>I have no need to have server control over an image.
> What is the best choice to use HTML img tag or asp:image for best
> performance?
> thanks,
> Goncalo Boleo
If there's no need to have a server control, then just use a <img> tag (primarily
for simplicity, even though it is faster but it's negligible). If you are
using a server control there's essentially no difference between the HtmlControls
and the WebContorls.

-Brock
DevelopMentor
http://staff.develop.com/ballen

> I have no need to have server control over an image.
> What is the best choice to use HTML img tag or asp:image for best
> performance?
> thanks,
> Goncalo Boleo

html image percentage issue

I am unable display an image by percent. No matter what method I try,
I receive the following error.

Input string was not in the correct format.

No matter what method I use, I cannot get this to show up in a percent
format. What am I missing here.

currentStatusImage.Src = "../builds/images/green.gif"
currentStatusImage.Width = "60%"

Thanks.currentStatusImage.Width is expecting a Unit, not a string, so you need to
do a Unit.Parse("60%") or a Unit.Percentage(60).

HTH,

Bill Priess

On 23 Jul 2003 13:29:33 -0700, Chris <chrisp@.webpositive.com> wrote:

> I am unable display an image by percent. No matter what method I try,
> I receive the following error.
> Input string was not in the correct format.
> No matter what method I use, I cannot get this to show up in a percent
> format. What am I missing here.
> currentStatusImage.Src = "../builds/images/green.gif"
> currentStatusImage.Width = "60%"
> Thanks.

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
I get an error stating that unit cannot convert to an integer, on both of
those attempts.

"Bill Priess" <no.spam@.nospam.com> wrote in message
news:oprsr572hkcimqky@.localhost...
> currentStatusImage.Width is expecting a Unit, not a string, so you need to
> do a Unit.Parse("60%") or a Unit.Percentage(60).
> HTH,
> Bill Priess
> On 23 Jul 2003 13:29:33 -0700, Chris <chrisp@.webpositive.com> wrote:
> > I am unable display an image by percent. No matter what method I try,
> > I receive the following error.
> > Input string was not in the correct format.
> > No matter what method I use, I cannot get this to show up in a percent
> > format. What am I missing here.
> > currentStatusImage.Src = "../builds/images/green.gif"
> > currentStatusImage.Width = "60%"
> > Thanks.
>
> --
> Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
From the documentation:

HtmlImage.Width Property

Gets or sets the width of the image.

Public Property Width As Integer

Property Value

The width of the image.

--
John Saunders
Internet Engineer
john.saunders@.surfcontrol.com

"Chris" <chrisp@.webpositive.com> wrote in message
news:1058997574.400832@.sj-nntpcache-5...
> I get an error stating that unit cannot convert to an integer, on both of
> those attempts.
>
> "Bill Priess" <no.spam@.nospam.com> wrote in message
> news:oprsr572hkcimqky@.localhost...
> > currentStatusImage.Width is expecting a Unit, not a string, so you need
to
> > do a Unit.Parse("60%") or a Unit.Percentage(60).
> > HTH,
> > Bill Priess
> > On 23 Jul 2003 13:29:33 -0700, Chris <chrisp@.webpositive.com> wrote:
> > > I am unable display an image by percent. No matter what method I try,
> > > I receive the following error.
> > > > Input string was not in the correct format.
> > > > No matter what method I use, I cannot get this to show up in a percent
> > > format. What am I missing here.
> > > > currentStatusImage.Src = "../builds/images/green.gif"
> > > currentStatusImage.Width = "60%"
> > > > Thanks.
> > > --
> > Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
It does, the sdk also states that you can also set the value as a
percentage. The problem is that it doesn't give an example or any
detail to that.

"By default, the Width property is expressed in pixels, but it can
also be expressed as a percentage of the window size." - straight from
the windows sdk, and that's all it has to say about it. But how??

http://msdn.microsoft.com/library/d...idthtop ic.asp

"John Saunders" <john.saunders@.surfcontrol.com> wrote in message news:<Ouy$DqWUDHA.2308@.TK2MSFTNGP12.phx.gbl>...
> From the documentation:
> HtmlImage.Width Property
> Gets or sets the width of the image.
> Public Property Width As Integer
> Property Value
> The width of the image.
> --
> John Saunders
> Internet Engineer
> john.saunders@.surfcontrol.com
>
> "Chris" <chrisp@.webpositive.com> wrote in message
> news:1058997574.400832@.sj-nntpcache-5...
> > I get an error stating that unit cannot convert to an integer, on both of
> > those attempts.
> > "Bill Priess" <no.spam@.nospam.com> wrote in message
> > news:oprsr572hkcimqky@.localhost...
> > > currentStatusImage.Width is expecting a Unit, not a string, so you need
> to
> > > do a Unit.Parse("60%") or a Unit.Percentage(60).
> > > > HTH,
> > > > Bill Priess
> > > > On 23 Jul 2003 13:29:33 -0700, Chris <chrisp@.webpositive.com> wrote:
> > > > > I am unable display an image by percent. No matter what method I try,
> > > > I receive the following error.
> > > > > > Input string was not in the correct format.
> > > > > > No matter what method I use, I cannot get this to show up in a percent
> > > > format. What am I missing here.
> > > > > > currentStatusImage.Src = "../builds/images/green.gif"
> > > > currentStatusImage.Width = "60%"
> > > > > > Thanks.
> > > > > > > > --
> > > Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
It seems you've found a documentation error.

An integer is an integer, not a Unit. You can't use percentage in an
HtmlImage.

John Saunders
john.saunders@.surfcontrol.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
It seems you've found a documentation error.

An integer is an integer, not a Unit. You can't use percentage in an
HtmlImage.

John Saunders
john.saunders@.surfcontrol.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Any ideas on how to get around this. In addition to this being an issue,
when I attempt to do the following ( going back to my asp classic way of
thinking ) :

<img border="0" id="currentStatusImage" src="http://pics.10026.com/?src=<% = srcInfo %> width="<% =
widthInfo %>%" height="6" runat="server"
I still get the integer error. I'd rather not make this a static image but,
the list of ideas grows smaller. Thanks.

"John Saunders" <john.saunders@.surfcontrol.com> wrote in message
news:e5PAL8dUDHA.1484@.TK2MSFTNGP12.phx.gbl...
> It seems you've found a documentation error.
> An integer is an integer, not a Unit. You can't use percentage in an
> HtmlImage.
> John Saunders
> john.saunders@.surfcontrol.com
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
You're still getting the error because you've still got the control marked
as runat="server", which means it's an HtmlImage, which means that the Width
property is an integer.

Do you really need the image to be a server control?

And why not use style="WIDTH:100%" :

currentStatusImage.Style["WIDTH"] = "100%"

--
John Saunders
Internet Engineer
john.saunders@.surfcontrol.com

"Chris" <chrisp@.webpositive.com> wrote in message
news:1059061676.370476@.sj-nntpcache-3...
> Any ideas on how to get around this. In addition to this being an issue,
> when I attempt to do the following ( going back to my asp classic way of
> thinking ) :
> <img border="0" id="currentStatusImage" src="http://pics.10026.com/?src=<% = srcInfo %> width="<% =
> widthInfo %>%" height="6" runat="server">
> I still get the integer error. I'd rather not make this a static image
but,
> the list of ideas grows smaller. Thanks.
>
> "John Saunders" <john.saunders@.surfcontrol.com> wrote in message
> news:e5PAL8dUDHA.1484@.TK2MSFTNGP12.phx.gbl...
> > It seems you've found a documentation error.
> > An integer is an integer, not a Unit. You can't use percentage in an
> > HtmlImage.
> > John Saunders
> > john.saunders@.surfcontrol.com
> > *** Sent via Developersdex http://www.developersdex.com ***
> > Don't just participate in USENET...get rewarded for it!

HTML Image Control (and VB vs JavaScript)

I'm a VB programmer, somewhat new to VB.Net, and completely new to (and clueless with) ASP.Net

I'm trying to build a simple game as a programming exercise. I have HTML Image Controls in place, but when I look at the code behind, there doesnt seem to be an OnClick event. How can I add one ?

Also, it seems possible to add a client side OnClick event from HTML View. But everytime I try it, Visual Studio wants JavaScript. This seems pointless to me, at best I can fumble my way through JavaScript, but as a VB programmer, what i WANT to do is write this in VB. There has to be a way to change the language to VB, right ?

BTW, I notice in some language drop downs (that I dont yet know how to use) there is "vb" and "visualbasic". What's that all about ?

Thanks, (a very frustrated) AARRGGHHH> I have HTML Image Controls in place, but when I look at the code behind, there doesnt seem to be an OnClick event. How can I add one ?

Change your HTML Image controls intoImage Buttons, which do indeed expose an onClick event.

> There has to be a way to change the (Javascript) language to VB, right ?

Wrong. Javascript works with the HTML's document model. It is client-side script. For example, using Javascript you can bounce an image of a ball around the screen. Such client-side operations are meaningless to a server-side language such as VB.NET.

For example, if you're making an internet game, you'd really want use as much Javascript as possible. If every "gamer action" causes the page to return to the server, it will be a slow game indeed.

> BTW, I notice in some language drop downs (that I dont yet know how to use) there is "vb" and "visualbasic". What's that all about ?

No idea. There's a few "flavours" of Visual Basic ... so, the dropdown options could mean anything.

As you're new to ASP.NET, you might like to work through theQuickStart Tutorials, as they have been specifically designed to teach you the fundamentals.

I hope this helps.
> Change your HTML Image controls into Image Buttons, which do indeed expose an onClick event.

Thanks for the suggestion, that seems to be working out well.

>> There has to be a way to change the (Javascript) language to VB, right ?

>Wrong. Javascript works with the HTML's document model. It is client-side script.

In that case, I'm guessing I can probably at least use VBScript for client side issues, correct ? Do I just change the language attribute to "VBScript" ?

> For example, if you're making an internet game, you'd really want use as much Javascript as possible. If every "gamer action" causes the page to return to the server, it will be a slow game indeed.

It's not an action game, just a simple question and answer game, so server side should work out fine.

Thanks again for your help
> I'm guessing I can probably at least use VBScript for client side issues, correct?

You could, but you shouldn't. Read:Good or Evil? VBScript on the client side.

Javascript is the way to go. In your case, with a question and answer game, there's probably little if any client-side scripting necessary.

Understanding Javascript is anextremely valuable skill for anyone creating websites or web applications.

I hope this helps.

HTML Image buttons

Hello,

I am using HTML image buttons in my web application and
when I run it, all my image buttons are showing up with a
border.

I tried using border="0" with the input tag, but it is
deprecated.

<input border="0" src="http://pics.10026.com/?src=../images/next.jpg"
type="image" onclick="return checkPage('next');"
runat="server"/
Can anyone suggest me an alternative?

Thanks!

HTML Image buttons

Hello,

I am using HTML image buttons in my web application and
when I run it, all my image buttons are showing up with a
border.

I tried using border="0" with the input tag, but it is
deprecated.

<input border="0" src="http://pics.10026.com/?src=../images/next.jpg"
type="image" onclick="return checkPage('next');"
runat="server"/
Can anyone suggest me an alternative?

Thanks!Hello,

Never had this issue, but you can try applying the "style" attribute
disabling any borders for the input control (provided the border is not the
focus frame indicating the control the keyboard input will be directed to).
You can inhibit the focus rect by adding HIDEFOCUS="true" but this will work
in IE only.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"itsme" <anonymous@.discussions.microsoft.com> wrote in message
news:082401c3984e$d5350a80$a101280a@.phx.gbl...
> Hello,
> I am using HTML image buttons in my web application and
> when I run it, all my image buttons are showing up with a
> border.
> I tried using border="0" with the input tag, but it is
> deprecated.
> <input border="0" src="http://pics.10026.com/?src=../images/next.jpg"
> type="image" onclick="return checkPage('next');"
> runat="server"/>
> Can anyone suggest me an alternative?
> Thanks!
Hello,

Never had this issue, but you can try applying the "style" attribute
disabling any borders for the input control (provided the border is not the
focus frame indicating the control the keyboard input will be directed to).
You can inhibit the focus rect by adding HIDEFOCUS="true" but this will work
in IE only.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"itsme" <anonymous@.discussions.microsoft.com> wrote in message
news:082401c3984e$d5350a80$a101280a@.phx.gbl...
> Hello,
> I am using HTML image buttons in my web application and
> when I run it, all my image buttons are showing up with a
> border.
> I tried using border="0" with the input tag, but it is
> deprecated.
> <input border="0" src="http://pics.10026.com/?src=../images/next.jpg"
> type="image" onclick="return checkPage('next');"
> runat="server"/>
> Can anyone suggest me an alternative?
> Thanks!

HTML Help

Hi,
I want to create Gradient color in my header (just like in microsoft
site) but we don;t want use the image for that and also it should work
in all browsers (If i use
filter:progid:DXImageTransform.Microsoft.Gradient, it works only in
IE). Please help me to solve this isse.

Thanks,
Jayhttp://slayeroffice.com/code/gradient/
"jaydev" <jaydev2605@.yahoo.comwrote in message news:1158958631.662572.139740@.d34g2000cwd.googlegr oups.com...

Quote:

Originally Posted by

Hi,
I want to create Gradient color in my header (just like in microsoft
site) but we don;t want use the image for that and also it should work
in all browsers (If i use
filter:progid:DXImageTransform.Microsoft.Gradient, it works only in
IE). Please help me to solve this isse.
>
Thanks,
Jay
>

HTML Help

Hi,
I want to create Gradient color in my header (just like in microsoft
site) but we don;t want use the image for that and also it should work
in all browsers (If i use
filter:progid:DXImageTransform.Microsoft.Gradient, it works only in
IE). Please help me to solve this isse.
Thanks,
Jayhttp://slayeroffice.com/code/gradient/
"jaydev" <jaydev2605@.yahoo.com> wrote in message news:1158958631.662572.139740@.d34g2000cwd.
googlegroups.com...
> Hi,
> I want to create Gradient color in my header (just like in microsoft
> site) but we don;t want use the image for that and also it should work
> in all browsers (If i use
> filter:progid:DXImageTransform.Microsoft.Gradient, it works only in
> IE). Please help me to solve this isse.
> Thanks,
> Jay
>

Monday, March 26, 2012

html encoding dynamic link?

Hi,

don't know if this is the right category, but I think the question is pretty simple.

I've got a web user control wich contains an image tag. When the control loads, I want to set the ImageUrl property to something like this:
"~/WUC/ShowLogo.aspx?id=" + PartnerID + @dotnet.itags.org."&sz=" + Size

This page just takes the id and the given size and outputs a thumbnail from an image in the database.
Now the image doesn't show up. When I check the source of the rendered html page I see this:

<img id="ctl00_cph_pcMain_imgLogo" src="http://pics.10026.com/?src=WUC/ShowLogo.aspx?id=1&sz=75" style="border-width:0px;"/
pretty obvious where everything goes wrong.. It encodes the & tot & wich is not really a valid url..

My question: How do I stop the component, or prolly the page the component is on, from encoding the url?

Not sure what goes worng, it shouldn't encode it by default behaviour.

imgLogo.ImageURL = "/WUC/ShowLogo.aspx?id=" + PartnerID + "&sz=" + Size;

should work fine.
Can you show us the piece of code where you set the imageURL property ?


you're right, it shouldn't encode, I have no freaking idea why it won't..

code behind:

protected void Page_Load(object sender, EventArgs e)
{
imgLogo.ImageUrl = "~/WUC/ShowLogo.aspx?id=" + PartnerID + "&sz=" + Size;
lblTitle.Text = Title;
lnkInfo.NavigateUrl = @."~/Info.aspx?id=" + PartnerID;
}

page:

<table>
<tr>
<td><asp:Image runat="server" ID="imgLogo" /></td>
<td>
<asp:Label runat="server" ID="lblTitle" />
<br />
<asp:HyperLink runat="server" ID="lnkInfo">meer <asp:Image runat="server" ID="imgArrow" ImageUrl="~/media/images/doublearrow.gif" /></asp:HyperLink>
</td>
</tr>
</table
anyone got a clue?

Saturday, March 24, 2012

Html email with embeded image-background?

Hi

I want to create an email message that has an image background embeded in the email message Itself

Not referenced to an image on the server. Any one can help please.

html email with embedded images

Hi,
I know how to send emails from the .Net environment, even html mails.
But, what is the best way to add images to the html?
A URL to an image somewhere on some server is usually blocked nowadays,
so you need to send the image as attachment. I had some success when I
used the filename (without path) of the attachment as img-src.
Is that the only way or are there better methods?
A related question: some of these images might be stored in the database
or generated "on the fly", but the MailAttachment class uses filenames.
Is there any way to attach some document *without* storing it first?
If not, can I safely delete that temporary file directly after I send the
email to the server?
Hans KestingI don't believe you can embed images into an email with the .net mail.
I also have to send out email's with embedded images that came from a
database. I basically had to write my own SMTP client to replace the built
in .net version. You can also purchase a 3rd party package that will do
this. (I couldn't since our product is resold and it would cause licencing
issues)
Unfortunally I can't send my code...they would probably fire me! But I can
offer you a few pointers on what you should do. Writing you're own SMTP
client isn't as easy as it sounds...there's a lot of standards to follow.
I strongly recommend that you use a 3rd party package...maybe this:
http://www.quiksoft.com/emdotnet/comparison.asp
"Hans Kesting" <news.2.hansdk@.spamgourmet.com> wrote in message
news:OZp%23JhRsEHA.160@.TK2MSFTNGP11.phx.gbl...
> Hi,
> I know how to send emails from the .Net environment, even html mails.
> But, what is the best way to add images to the html?
> A URL to an image somewhere on some server is usually blocked nowadays,
> so you need to send the image as attachment. I had some success when I
> used the filename (without path) of the attachment as img-src.
> Is that the only way or are there better methods?
> A related question: some of these images might be stored in the database
> or generated "on the fly", but the MailAttachment class uses filenames.
> Is there any way to attach some document *without* storing it first?
> If not, can I safely delete that temporary file directly after I send the
> email to the server?
> Hans Kesting
>

html email with embedded images

Hi,

I know how to send emails from the .Net environment, even html mails.
But, what is the best way to add images to the html?

A URL to an image somewhere on some server is usually blocked nowadays,
so you need to send the image as attachment. I had some success when I
used the filename (without path) of the attachment as img-src.
Is that the only way or are there better methods?

A related question: some of these images might be stored in the database
or generated "on the fly", but the MailAttachment class uses filenames.
Is there any way to attach some document *without* storing it first?
If not, can I safely delete that temporary file directly after I send the
email to the server?

Hans KestingI don't believe you can embed images into an email with the .net mail.

I also have to send out email's with embedded images that came from a
database. I basically had to write my own SMTP client to replace the built
in .net version. You can also purchase a 3rd party package that will do
this. (I couldn't since our product is resold and it would cause licencing
issues)

Unfortunally I can't send my code...they would probably fire me! But I can
offer you a few pointers on what you should do. Writing you're own SMTP
client isn't as easy as it sounds...there's a lot of standards to follow.
I strongly recommend that you use a 3rd party package...maybe this:
http://www.quiksoft.com/emdotnet/comparison.asp

"Hans Kesting" <news.2.hansdk@.spamgourmet.com> wrote in message
news:OZp%23JhRsEHA.160@.TK2MSFTNGP11.phx.gbl...
> Hi,
> I know how to send emails from the .Net environment, even html mails.
> But, what is the best way to add images to the html?
> A URL to an image somewhere on some server is usually blocked nowadays,
> so you need to send the image as attachment. I had some success when I
> used the filename (without path) of the attachment as img-src.
> Is that the only way or are there better methods?
> A related question: some of these images might be stored in the database
> or generated "on the fly", but the MailAttachment class uses filenames.
> Is there any way to attach some document *without* storing it first?
> If not, can I safely delete that temporary file directly after I send the
> email to the server?
> Hans Kesting

Html email and embedded images.

Is it possible to embed an image in an html email without a mail component.
If so can you post an example.
Thanks
Ok now I know it is not possible without a component. Is there a freecomponent around that lets you imbed images in to html emails?

Thursday, March 22, 2012

HTML code blocked by Response.OutputStream.Write

I'm working on a site that creates mailing labels. When a label is
generated, two things happen in the background with the image.

First, it is saved as a smaller low-quality .gif on the server and
then presented as a preview using an img tag (also later used for a
history feature on the site).

Second, when the user clicks on the image, a new window appears with
only the mailing label as a high-quality .png graphic. I don't save
the .png image to conserve hardrive space, so I use
response.outputstream.write to output the image array. I do this
because it is important to have crisp barcodes on the labels.

The problem is that by doing this, the html in the aspx file isn't
sent to the client, just the image. I would like to use
window.print() on the client side. I tried using
Page.RegisterStartUpScript; it runs, but isn't output to the user no
matter if it is ran before or after the OutputStream.

Anyone else seen a similar problem?

Is there a way to display an image that is in server memory to an
image tag?Richard wrote:
> Is there a way to display an image that is in server memory to an
> image tag?

Yes there is. Set the img src to a aspx page:

<img src="http://pics.10026.com/?src=myImageWriter.aspx".../
myImageWriter.aspx must only output your binary data for the image, by
changing the content-type and then using Response.BinaryWrite to write
the bytes to the response stream. Here's one example, look at
ViewImage.aspx and its code-behind:

http://www.developerfusion.com/show/3933/4/

Sorry, it's actually a halfway-there example, but the only one I could
find. Note you should do a Response.Clear before doing anything else
with the Response object. A Response.Flush and Response.End afterwards
would really make sure no extraneous output (HTML, text, etc.) makes it
along with the binary. And make sure you don't set Response.Buffer =
false (by default it's true).

--
Craig Deelsnyder
Microsoft MVP - ASP.NET
Nice little trick and it works great for my project. Thanks for the
help.

I still curious why the outputstream was overwriting the html. Is it
supposed to this?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Richard Huff wrote:

> Nice little trick and it works great for my project. Thanks for the
> help.
> I still curious why the outputstream was overwriting the html. Is it
> supposed to this?
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

Um, not sure. Was there a Response.Flush/Response.End somewhere in the
code? The HTML in your page (as you pry see it in your .aspx) isn't
output until after Page_Load (and other page related events) run. Via
the Render event/method (once again assuming the default of .Buffer =
true).

Outputting more than one MIME type in the same stream usually corrupts
the stream (the browser doesn't know what it is, like a corrupted file
in Windows). At least I thought so...

--
Craig Deelsnyder
Microsoft MVP - ASP.NET

Wednesday, March 21, 2012

html at end of download - urgent please help!

hi there

i have the following bit of code that downloads/uploads documents from
a sql database.

the problem i have is when i download an image for example and look at
it in notepad i see the binary data and below it the html from the page
the image was downloaded from. so my 10k image is now 32k.

please any help would be much appreciated.

thanks

shawn

Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnUpload.Click
Dim iLength As Integer =
CType(LifeFileUpload.PostedFile.InputStream.Length , Integer)
If iLength = 0 Then Exit Sub 'not a valid file
Dim sContentType As String =
LifeFileUpload.PostedFile.ContentType
Dim sFileName As String, i As Integer
Dim bytContent As Byte()
ReDim bytContent(iLength)

'strip the path off the filename
i = InStrRev(LifeFileUpload.PostedFile.FileName.Trim, "\")
If i = 0 Then
sFileName = LifeFileUpload.PostedFile.FileName.Trim
Else
sFileName = Right(LifeFileUpload.PostedFile.FileName.Trim,
Len(LifeFileUpload.PostedFile.FileName.Trim) - i)
End If

LifeFileUpload.PostedFile.InputStream.Read(bytCont ent, 0,
iLength)

objDonkey.SelectedClient.AddDocument(objDonkey.Use rName,
sFileName, sContentType, iLength, bytContent, "this is a test
document")

End Sub

Protected Sub btnGetDoc_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnGetDoc.Click
Dim DocId As Integer
Dim objDoc As Life.Clients.Client.DocumentItem

DocId = HiddenSelectedDoc.Value
objDonkey.SelectedClient.GetDocuments()
objDoc = objDonkey.SelectedClient.DocumentList(DocId)

Response.Buffer = True
Response.Expires = -1
Response.ClearContent()
Response.ClearHeaders()

Response.ContentType = "image/jpeg" 'objDoc.ContentType

Response.OutputStream.Write(CType(objDonkey.Select edClient.GetDocument(DocId),
Byte()), 0, CInt(objDoc.ContentLegnth))
Response.AddHeader("Content-Disposition",
"attachment;filename=" + objDoc.Filename)
Response.Flush()

End SubHi Shawn,

Try to clear the response object after the following code:

Response.Buffer = True
Response.Expires = -1
Response.ClearContent()
Response.ClearHeaders()
// Clear the response object.
Response.Clear();

And then when you finished writing into the response stream:

Response.Flush();
Response.End();

I think it might help.

See ya.

Thiago Oliveira

shawn_vandenberg@.yahoo.com escreveu:

Quote:

Originally Posted by

hi there
>
i have the following bit of code that downloads/uploads documents from
a sql database.
>
the problem i have is when i download an image for example and look at
it in notepad i see the binary data and below it the html from the page
the image was downloaded from. so my 10k image is now 32k.
>
please any help would be much appreciated.
>
thanks
>
shawn
>
>
>
Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnUpload.Click
Dim iLength As Integer =
CType(LifeFileUpload.PostedFile.InputStream.Length , Integer)
If iLength = 0 Then Exit Sub 'not a valid file
Dim sContentType As String =
LifeFileUpload.PostedFile.ContentType
Dim sFileName As String, i As Integer
Dim bytContent As Byte()
ReDim bytContent(iLength)
>
'strip the path off the filename
i = InStrRev(LifeFileUpload.PostedFile.FileName.Trim, "\")
If i = 0 Then
sFileName = LifeFileUpload.PostedFile.FileName.Trim
Else
sFileName = Right(LifeFileUpload.PostedFile.FileName.Trim,
Len(LifeFileUpload.PostedFile.FileName.Trim) - i)
End If
>
LifeFileUpload.PostedFile.InputStream.Read(bytCont ent, 0,
iLength)
>
objDonkey.SelectedClient.AddDocument(objDonkey.Use rName,
sFileName, sContentType, iLength, bytContent, "this is a test
document")
>
>
End Sub
>
Protected Sub btnGetDoc_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnGetDoc.Click
Dim DocId As Integer
Dim objDoc As Life.Clients.Client.DocumentItem
>
DocId = HiddenSelectedDoc.Value
objDonkey.SelectedClient.GetDocuments()
objDoc = objDonkey.SelectedClient.DocumentList(DocId)
>
>
Response.Buffer = True
Response.Expires = -1
Response.ClearContent()
Response.ClearHeaders()
>
Response.ContentType = "image/jpeg" 'objDoc.ContentType
>
Response.OutputStream.Write(CType(objDonkey.Select edClient.GetDocument(DocId),
Byte()), 0, CInt(objDoc.ContentLegnth))
Response.AddHeader("Content-Disposition",
"attachment;filename=" + objDoc.Filename)
Response.Flush()
>
>
End Sub

html at end of download - urgent please help!

hi there
i have the following bit of code that downloads/uploads documents from
a sql database.
the problem i have is when i download an image for example and look at
it in notepad i see the binary data and below it the html from the page
the image was downloaded from. so my 10k image is now 32k.
please any help would be much appreciated.
thanks
shawn
Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnUpload.Click
Dim iLength As Integer =
CType(LifeFileUpload.PostedFile.InputStream.Length, Integer)
If iLength = 0 Then Exit Sub 'not a valid file
Dim sContentType As String =
LifeFileUpload.PostedFile.ContentType
Dim sFileName As String, i As Integer
Dim bytContent As Byte()
ReDim bytContent(iLength)
'strip the path off the filename
i = InStrRev(LifeFileUpload.PostedFile.FileName.Trim, "\")
If i = 0 Then
sFileName = LifeFileUpload.PostedFile.FileName.Trim
Else
sFileName = Right(LifeFileUpload.PostedFile.FileName.Trim,
Len(LifeFileUpload.PostedFile.FileName.Trim) - i)
End If
LifeFileUpload.PostedFile.InputStream.Read(bytContent, 0,
iLength)
objDonkey.SelectedClient.AddDocument(objDonkey.UserName,
sFileName, sContentType, iLength, bytContent, "this is a test
document")
End Sub
Protected Sub btnGetDoc_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnGetDoc.Click
Dim DocId As Integer
Dim objDoc As Life.Clients.Client.DocumentItem
DocId = HiddenSelectedDoc.Value
objDonkey.SelectedClient.GetDocuments()
objDoc = objDonkey.SelectedClient.DocumentList(DocId)
Response.Buffer = True
Response.Expires = -1
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "image/jpeg" 'objDoc.ContentType
Response.OutputStream.Write(CType(objDonkey.SelectedClient.GetDocument(DocId
),
Byte()), 0, CInt(objDoc.ContentLegnth))
Response.AddHeader("Content-Disposition",
"attachment;filename=" + objDoc.Filename)
Response.Flush()
End SubHi Shawn,
Try to clear the response object after the following code:
Response.Buffer = True
Response.Expires = -1
Response.ClearContent()
Response.ClearHeaders()
// Clear the response object.
Response.Clear();
And then when you finished writing into the response stream:
Response.Flush();
Response.End();
I think it might help.
See ya.
Thiago Oliveira
shawn_vandenberg@.yahoo.com escreveu:

> hi there
> i have the following bit of code that downloads/uploads documents from
> a sql database.
> the problem i have is when i download an image for example and look at
> it in notepad i see the binary data and below it the html from the page
> the image was downloaded from. so my 10k image is now 32k.
> please any help would be much appreciated.
> thanks
> shawn
>
> Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles btnUpload.Click
> Dim iLength As Integer =
> CType(LifeFileUpload.PostedFile.InputStream.Length, Integer)
> If iLength = 0 Then Exit Sub 'not a valid file
> Dim sContentType As String =
> LifeFileUpload.PostedFile.ContentType
> Dim sFileName As String, i As Integer
> Dim bytContent As Byte()
> ReDim bytContent(iLength)
> 'strip the path off the filename
> i = InStrRev(LifeFileUpload.PostedFile.FileName.Trim, "\")
> If i = 0 Then
> sFileName = LifeFileUpload.PostedFile.FileName.Trim
> Else
> sFileName = Right(LifeFileUpload.PostedFile.FileName.Trim,
> Len(LifeFileUpload.PostedFile.FileName.Trim) - i)
> End If
> LifeFileUpload.PostedFile.InputStream.Read(bytContent, 0,
> iLength)
> objDonkey.SelectedClient.AddDocument(objDonkey.UserName,
> sFileName, sContentType, iLength, bytContent, "this is a test
> document")
>
> End Sub
> Protected Sub btnGetDoc_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles btnGetDoc.Click
> Dim DocId As Integer
> Dim objDoc As Life.Clients.Client.DocumentItem
> DocId = HiddenSelectedDoc.Value
> objDonkey.SelectedClient.GetDocuments()
> objDoc = objDonkey.SelectedClient.DocumentList(DocId)
>
> Response.Buffer = True
> Response.Expires = -1
> Response.ClearContent()
> Response.ClearHeaders()
> Response.ContentType = "image/jpeg" 'objDoc.ContentType
> Response.OutputStream.Write(CType(objDonkey.SelectedClient.GetDocument(Doc
Id),
> Byte()), 0, CInt(objDoc.ContentLegnth))
> Response.AddHeader("Content-Disposition",
> "attachment;filename=" + objDoc.Filename)
> Response.Flush()
>
> End Sub

HTML 101 Position image relative to GridView row

This seems like it should be simple and I am pretty sure I've done similar
things a hundred times before but I sure can't seem to get it right this tim
e.
I have a GridView with a column of text boxes. If I want to position an
image over the GridView just below, for instance, the textbox in row 4 of th
e
GridView. I don't care that it covers the other textboxes. I am
successfully obtaining the textbox and the image objects in client-side
javascript using document.getElementById().
I can position the image just fine. I just can't seem to get the position
of the chosen textbox relative to the screen or client area of the browser.
textBox.offsetTop = 2 // this seems to be the position relative to the cell
in the table of the rendered GridView
textBox.clientTop = 2 // this seems to be the position relative to the cell
in the table of the rendered GridView
textBox.style.pixelTop = 0
textBox.style.top = // empty
Dale Preston
MCAD C#
MCSE, MCDBAI clicked "post" too quickly. I wish there was a Review button to see your
post before finally submitting it.
Anyway, what my original post left out is what it is I am looking for:
Can anyone help me with how to get the location of an item in a GridView
row, in my case the textbox, in relation to either the document or in
relation to the client area of the browser so that I can position my image i
n
relation to that textbox?
Thanks,
Dale
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Dale" wrote:

> This seems like it should be simple and I am pretty sure I've done similar
> things a hundred times before but I sure can't seem to get it right this t
ime.
> I have a GridView with a column of text boxes. If I want to position an
> image over the GridView just below, for instance, the textbox in row 4 of
the
> GridView. I don't care that it covers the other textboxes. I am
> successfully obtaining the textbox and the image objects in client-side
> javascript using document.getElementById().
> I can position the image just fine. I just can't seem to get the position
> of the chosen textbox relative to the screen or client area of the browser
.
> textBox.offsetTop = 2 // this seems to be the position relative to the cel
l
> in the table of the rendered GridView
> textBox.clientTop = 2 // this seems to be the position relative to the cel
l
> in the table of the rendered GridView
> textBox.style.pixelTop = 0
> textBox.style.top = // empty
>
> --
> Dale Preston
> MCAD C#
> MCSE, MCDBA
I solved my own problem. The solution is to add a POSITION style value of
"relative" to the textbox. Then offsetTop and offsetLeft provide real value
s
relative to the client area.
Dale Preston
MCAD C#
MCSE, MCDBA
"Dale" wrote:

> This seems like it should be simple and I am pretty sure I've done similar
> things a hundred times before but I sure can't seem to get it right this t
ime.
> I have a GridView with a column of text boxes. If I want to position an
> image over the GridView just below, for instance, the textbox in row 4 of
the
> GridView. I don't care that it covers the other textboxes. I am
> successfully obtaining the textbox and the image objects in client-side
> javascript using document.getElementById().
> I can position the image just fine. I just can't seem to get the position
> of the chosen textbox relative to the screen or client area of the browser
.
> textBox.offsetTop = 2 // this seems to be the position relative to the cel
l
> in the table of the rendered GridView
> textBox.clientTop = 2 // this seems to be the position relative to the cel
l
> in the table of the rendered GridView
> textBox.style.pixelTop = 0
> textBox.style.top = // empty
>
> --
> Dale Preston
> MCAD C#
> MCSE, MCDBA

HTML 101 Position image relative to GridView row

This seems like it should be simple and I am pretty sure I've done similar
things a hundred times before but I sure can't seem to get it right this time.

I have a GridView with a column of text boxes. If I want to position an
image over the GridView just below, for instance, the textbox in row 4 of the
GridView. I don't care that it covers the other textboxes. I am
successfully obtaining the textbox and the image objects in client-side
javascript using document.getElementById().

I can position the image just fine. I just can't seem to get the position
of the chosen textbox relative to the screen or client area of the browser.

textBox.offsetTop = 2 // this seems to be the position relative to the cell
in the table of the rendered GridView

textBox.clientTop = 2 // this seems to be the position relative to the cell
in the table of the rendered GridView

textBox.style.pixelTop = 0

textBox.style.top = // empty

--
Dale Preston
MCAD C#
MCSE, MCDBAI clicked "post" too quickly. I wish there was a Review button to see your
post before finally submitting it.

Anyway, what my original post left out is what it is I am looking for:

Can anyone help me with how to get the location of an item in a GridView
row, in my case the textbox, in relation to either the document or in
relation to the client area of the browser so that I can position my image in
relation to that textbox?

Thanks,

Dale
--
Dale Preston
MCAD C#
MCSE, MCDBA

"Dale" wrote:

Quote:

Originally Posted by

This seems like it should be simple and I am pretty sure I've done similar
things a hundred times before but I sure can't seem to get it right this time.
>
I have a GridView with a column of text boxes. If I want to position an
image over the GridView just below, for instance, the textbox in row 4 of the
GridView. I don't care that it covers the other textboxes. I am
successfully obtaining the textbox and the image objects in client-side
javascript using document.getElementById().
>
I can position the image just fine. I just can't seem to get the position
of the chosen textbox relative to the screen or client area of the browser.
>
textBox.offsetTop = 2 // this seems to be the position relative to the cell
in the table of the rendered GridView
>
textBox.clientTop = 2 // this seems to be the position relative to the cell
in the table of the rendered GridView
>
textBox.style.pixelTop = 0
>
textBox.style.top = // empty
>
>
--
Dale Preston
MCAD C#
MCSE, MCDBA


I solved my own problem. The solution is to add a POSITION style value of
"relative" to the textbox. Then offsetTop and offsetLeft provide real values
relative to the client area.

--
Dale Preston
MCAD C#
MCSE, MCDBA

"Dale" wrote:

Quote:

Originally Posted by

This seems like it should be simple and I am pretty sure I've done similar
things a hundred times before but I sure can't seem to get it right this time.
>
I have a GridView with a column of text boxes. If I want to position an
image over the GridView just below, for instance, the textbox in row 4 of the
GridView. I don't care that it covers the other textboxes. I am
successfully obtaining the textbox and the image objects in client-side
javascript using document.getElementById().
>
I can position the image just fine. I just can't seem to get the position
of the chosen textbox relative to the screen or client area of the browser.
>
textBox.offsetTop = 2 // this seems to be the position relative to the cell
in the table of the rendered GridView
>
textBox.clientTop = 2 // this seems to be the position relative to the cell
in the table of the rendered GridView
>
textBox.style.pixelTop = 0
>
textBox.style.top = // empty
>
>
--
Dale Preston
MCAD C#
MCSE, MCDBA