Showing posts with label string. Show all posts
Showing posts with label string. Show all posts

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 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!

Monday, March 26, 2012

Html for control

Hi,

Is it possible to get the html for a control? ie. return to a string what
the RenderControl method would output.

Thanks

DonalIf it's your own control you should be able to get it from within the render
event.
If it's not your control then you should be able to call the RenderControl
method of the control to get its output.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"Donal McWeeney" <donal_mcweeney@.NO-SP-AM.aimware.com> wrote in message
news:Oea88pykDHA.2676@.TK2MSFTNGP11.phx.gbl...
> Hi,
> Is it possible to get the html for a control? ie. return to a string what
> the RenderControl method would output.
> Thanks
> Donal
Thanks... think it kindof answers the question...

"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
news:OeGaRJ0kDHA.1800@.TK2MSFTNGP10.phx.gbl...
> If it's your own control you should be able to get it from within the
render
> event.
> If it's not your control then you should be able to call the RenderControl
> method of the control to get its output.
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://Steve.Orr.net
> Hire top-notch developers at http://www.able-consulting.com
>
> "Donal McWeeney" <donal_mcweeney@.NO-SP-AM.aimware.com> wrote in message
> news:Oea88pykDHA.2676@.TK2MSFTNGP11.phx.gbl...
> > Hi,
> > Is it possible to get the html for a control? ie. return to a string
what
> > the RenderControl method would output.
> > Thanks
> > Donal

HTML entity utility class

Does anyone know of a class or component that maps to and fromHTML entities?

That is, I can pass to it the string "Green Eggs & Ham" and have returned "Green Eggs & Ham", and visa-versa?

Thanks to anyone who can save me the effort of having to type in all these entities myself...

Html encoding SOAP response

Is there anyway I can make my xml webservice not htmlencode the response
from a call to an API?

I have:
public int PerformOperation(string operation, out string result)

The content of result is html encoded, but since it contains valid xml,
I should get away with not htmlencoding it, or not?

<soap:Body
<PerformOperationResponse xmlns="http://tempuri.org/"
<PerformOperationResult
0

</PerformOperationResult
<result
<RetrieveTreeResponse id="123"
<Node id="1"
title="TopLevelNode1"
<Node id="2"
title="2LevelNode1" /
<Node id="3"
title="2LevelNode2" /
</Node
<Node id="4"
title="TopLevelNode2" /
</RetrieveTreeResponse
</result
</PerformOperationResponse
</soap:Body
Casper Hornstrup wrote:

> Is there anyway I can make my xml webservice not htmlencode the response
> from a call to an API?
> I have:
> public int PerformOperation(string operation, out string result)
> The content of result is html encoded, but since it contains valid xml,
> I should get away with not htmlencoding it, or not?

Try to use a parameter of type XmlNode instead of a string.

> <soap:Body>
> <PerformOperationResponse xmlns="http://tempuri.org/">
> <PerformOperationResult>
> 0
> </PerformOperationResult>
> <result>
> <RetrieveTreeResponse id="123">
> <Node id="1"
> title="TopLevelNode1">
> <Node id="2"
> title="2LevelNode1" />
> <Node id="3"
> title="2LevelNode2" />
> </Node>
> <Node id="4"
> title="TopLevelNode2" />
> </RetrieveTreeResponse>
> </result>
> </PerformOperationResponse>
> </soap:Body>
>

--

Martin Honnen
http://JavaScript.FAQTs.com/

HTML encoding of asp controls.

I find that the HTML encoding of asp web controls are inconsistent.

Say, I want to show the string "<script> alter("test") <script>". For a
"BoundColumn" used in DataGrid, I get an *real alert box* instead
of the string. In order for it to be shown correctly, I have to call
"Server.HtmlEncode" before set the text.

But if I use "asp:TextBox" control, I can not do "Server.HtmlEncode"
before I set the text. Otherwise, I will see this on my web page: "<..."

Is there a general rule, or documentation of which controls will do HTML
encoding automatically, which don't?

Thanks,
Guogang

Saturday, March 24, 2012

html encoding and the plus sign

Hi,

I am trying to pass a parameter string from one page to another. This string may contain all sorts of characters ( ie whateever may be in an encrypted string such as "+" and "=" etc etc )

I am using Request.QueryString to obtain the value - even though I am using HttpUtility.Encode and Decode, it seems that it does not preserve the "+" sign - so therefore I replace the plus sign in the original string with some unique string then after it is decoded the string has the plus signs put back in by replacing the unique string.

This works for me.

My question is:

Do I have to worry about any other characters that could be a problem that HttpUtility.Encode does not handle but have some special meaning besides the plus sign?

Thanks

-Barb

Hi,

did you already try out theUrlEncode and UrlDecode methods? These helped me out in the recent past when I had to pass the # sign in the querystring and HtmlDecode / HtmlEncode didn't really help me out. Just my 2 cents.

Grz, Kris.


Thanks for your reply

You are right Html/Encode Decode actually does not really do what I want - it may change some special characters to another representation but they are still interpreted as special characters - The ones that seem to be a problem are + " : < > # and & For these, I replace them each with a special unique string then in the receiving page replace them back to what they should be. After testing , passing all characters on the keyboard, I only seem to have a problem with these - Do you know of anything else that could be a potential problem?

thanks

Barb


Hi,

instead of creating your own code for this you could also try out the UrlEncode and UrlDecode. It really helped me out when I had problems with certain characters in the querystring. Just take 5 - 10 minutes to set up a little sample application and experiment with it.

Grz, Kris.

Thursday, March 22, 2012

HTML Contents in GridView Rows Will Not Display as HTML?

Hello all,
I am trying to read a directory listing into a string[] and then use
that data, along with some other data, to create HTML for display in a
gridview row. A sample item in the string[] might look like this...
<div style='vertical-align:middle;'><img src='image.jpb'><a
href='somefile.zip'>somefile.zip</a></div>
I then bind the array to a gridview to show on the form.
This always worked great with a datagrid in VS2003. Now, however, the
gridview handles the HTML differently: if reformats it? What I mean is,
the HTML displays as literal text...the gridview rows really show the
HTML tags (<div>, etc...). When inspecting the page with the browser's
View | Source, I can see that the page has all of the <div> as < div
>. Why is this happening, and how do I fix it? It would be great if
asp.net would not change my code!

HTML Contents in GridView Rows Will Not Display as HTML?

Hello all,

I am trying to read a directory listing into a string[] and then use
that data, along with some other data, to create HTML for display in a
gridview row. A sample item in the string[] might look like this...

<div style='vertical-align:middle;'><img src='image.jpb'><a
href='somefile.zip'>somefile.zip</a></div
I then bind the array to a gridview to show on the form.

This always worked great with a datagrid in VS2003. Now, however, the
gridview handles the HTML differently: if reformats it? What I mean is,
the HTML displays as literal text...the gridview rows really show the
HTML tags (<div>, etc...). When inspecting the page with the browser's
View | Source, I can see that the page has all of the <div> as < div
>. Why is this happening, and how do I fix it? It would be great if
asp.net would not change my code!

Wednesday, March 21, 2012

HTML call const value

I have a constants.vb file with the following:

Public Class Constants
Public Const strRedAsterisk As String = "<font color=""#FF3300"">*</font>"
End Class

I have a login.aspx page. In html I have code:


<TD width="25%">Login ID <%# Constants.strRedAsterisk%></TD>

I get an error? I response.write Constants.strRedAsterisk in behind code and it works.

How can I call it in HTML ?Hi,

Try this :

<TD width="25%">Login ID <%=Constants.strRedAsterisk%></TD>

HTH
No doesn't work.

I get error:

BC30456: 'strRedAsterisk' is not a member of 'Microsoft.VisualBasic.Constants'.

I don't get it.
I put it in another class file called class1.

error message:

Name 'Class1' is not declared.

In code behind of aspx page - it works... But not when I call it in html view page. Do I have to set something on the top of the page?
Hi,

Use namespace as below :


<TD width="25%">Login ID <%=YourApplicationNameSpace.Constants.strRedAsterisk%></TD>

HTH
Awesome. Thanks

Is there a command line I can use so it inherits namespace and I don't have to put namespace in front of constants?
Also what if my applicationname changes later on down the road. Isn't it better not to use namespace ?