Thursday, March 29, 2012

Html in Asp.Net variable causeing errors

I am using this code:

Dim strPopup as String = "<script>alert('hello world');</script>"

The closing script tag is screwing up the vb code. I don't know why..This is a protection to avoid script tags in asp.net code which can break the server-side scripts in ASP.NET (when a </script> is detected). Use this little workaround to solve the problem:

Dim strPopup as String = "<script>alert('hello world');</script"+">"
.
Another solution is to avoid the direct use of <script> tags by using the properties of, for example, the <body> section of the page:

<body onload="alert('hello world');">
...

HTML in a variable

Im using asp on a win2k3 server. I would like to put a lot of html into 1 variable. I get an error when i try to do it my way.


'Here is an example of what I would like to do, kinda.
application="<html>
<head>
<title>Join</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="http://links.10026.com/?link=join.css" rel="stylesheet" type="text/css">
</head>"


'Here is the error.
Microsoft VBScript compilation error '800a0409'

Unterminated string constant

/cfcs/join/mail.asp, line 17

application="<html>
------^

I was wondering if anyone could suggest an effective method of doing this.you should replace the double quotes(") by a single quote(') and instead of adding new line for the variable value you can use <br
application="<html><br><head><br><title>Join</title><br><meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'><br><link href='join.css' rel='stylesheet' type='text/css'><br></head></html>"

Hope this helps
Nitasha

------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.
this isn't an asp forum

application = "<html>" & vbCrLf & "<head>" & vbCrLf & "<title>Join</title>" & vbCrLf & "<meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"">" & _
vbCrLf & "<link href="http://links.10026.com/?link="join.css"" rel=""stylesheet"" type=""text/css"">" & vbCrLf & "</head>"
The new lines in the string are not understood by VB.

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 IMG SRC

Hello,
I am dealing with a lot of published pages on a particular website.
(web-editor/publish/archive) It is easier for me to remove all of the
"../../imgageDir/image001.jpg" references and replace then with
http://www.aWebsite.com/imageDir/image001.jpg...
Will this slow down my website or the rendering of the html pages. It is
all happening on the same website (no external images)
ie,
<html><body>
<img src="http://pics.10026.com/?src=../../imageDir/image001.jpg">
<img src="http://pics.10026.com/?src=../../imageDir/image002.jpg">
</body></html>
---
OR
---
<html><body>
<img src="http://pics.10026.com/?src=http://www.aWebsite.com/imageDir/image001.jpg">
<img src="http://pics.10026.com/?src=http://www.aWebsite.com/imageDir/image002.jpg">
</body></html>
which one is faster?
THanks,
PaulNiether is faster. Both are the same.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.
"psb" <pbellman@.msn.com> wrote in message
news:%23gciQEeFFHA.2600@.TK2MSFTNGP09.phx.gbl...
> Hello,
> I am dealing with a lot of published pages on a particular website.
> (web-editor/publish/archive) It is easier for me to remove all of the
> "../../imgageDir/image001.jpg" references and replace then with
> http://www.aWebsite.com/imageDir/image001.jpg...
> Will this slow down my website or the rendering of the html pages. It is
> all happening on the same website (no external images)
> ie,
> <html><body>
> <img src="http://pics.10026.com/?src=../../imageDir/image001.jpg">
> <img src="http://pics.10026.com/?src=../../imageDir/image002.jpg">
> </body></html>
> ---
> OR
> ---
> <html><body>
> <img src="http://pics.10026.com/?src=http://www.aWebsite.com/imageDir/image001.jpg">
> <img src="http://pics.10026.com/?src=http://www.aWebsite.com/imageDir/image002.jpg">
> </body></html>
> which one is faster?
> THanks,
> Paul
>

HTML IMG SRC

Hello,
I am dealing with a lot of published pages on a particular website.
(web-editor/publish/archive) It is easier for me to remove all of the
"../../imgageDir/image001.jpg" references and replace then with
http://www.aWebsite.com/imageDir/image001.jpg...

Will this slow down my website or the rendering of the html pages. It is
all happening on the same website (no external images)

ie,

<html><body>
<img src="http://pics.10026.com/?src=../../imageDir/image001.jpg">
<img src="http://pics.10026.com/?src=../../imageDir/image002.jpg">
</body></html>
------------
OR
------------
<html><body>
<img src="http://pics.10026.com/?src=http://www.aWebsite.com/imageDir/image001.jpg">
<img src="http://pics.10026.com/?src=http://www.aWebsite.com/imageDir/image002.jpg">
</body></html
which one is faster?
THanks,
PaulNiether is faster. Both are the same.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"psb" <pbellman@.msn.com> wrote in message
news:%23gciQEeFFHA.2600@.TK2MSFTNGP09.phx.gbl...
> Hello,
> I am dealing with a lot of published pages on a particular website.
> (web-editor/publish/archive) It is easier for me to remove all of the
> "../../imgageDir/image001.jpg" references and replace then with
> http://www.aWebsite.com/imageDir/image001.jpg...
> Will this slow down my website or the rendering of the html pages. It is
> all happening on the same website (no external images)
> ie,
> <html><body>
> <img src="http://pics.10026.com/?src=../../imageDir/image001.jpg">
> <img src="http://pics.10026.com/?src=../../imageDir/image002.jpg">
> </body></html>
> ------------
> OR
> ------------
> <html><body>
> <img src="http://pics.10026.com/?src=http://www.aWebsite.com/imageDir/image001.jpg">
> <img src="http://pics.10026.com/?src=http://www.aWebsite.com/imageDir/image002.jpg">
> </body></html>
> which one is faster?
> THanks,
> Paul

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!