Quotes from database to textbox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joeandtel

    Quotes from database to textbox

    I have a form that asks for the size of a particular object. Sometimes the size is 4" X 8". The problem that arises is when the record is pulled back from a database to a textbox in a form; I get an error with HTML. I try and place the 4" X 8" into a text box, like <input type="text" name="size" value="4" X 8""> Is there something I can do in ASP to keep this from happening after the client receives the data?
  • Ray at

    #2
    Re: Quotes from database to textbox

    <input type="text" value="<%=Serve r.HTMLEncode(Yo urValue)%>">

    Ray at work

    "Joeandtel" <anonymous@disc ussions.microso ft.com> wrote in message
    news:A9C66CE5-9453-4950-AB8B-30BF8FD1C202@mi crosoft.com...[color=blue]
    > I have a form that asks for the size of a particular object. Sometimes the[/color]
    size is 4" X 8". The problem that arises is when the record is pulled back
    from a database to a textbox in a form; I get an error with HTML. I try and
    place the 4" X 8" into a text box, like <input type="text" name="size"
    value="4" X 8""> Is there something I can do in ASP to keep this from
    happening after the client receives the data?


    Comment

    • Steven Burn

      #3
      Re: Quotes from database to textbox

      Server.URLEncod e(TheString)

      I'm pretty sure there's an HTMLEncode one aswell but, never had a need to
      know so can't say for sure.

      --
      Regards

      Steven Burn
      Ur I.T. Mate Group


      Keeping it FREE!

      Disclaimer:
      I know I'm probably wrong, I just like taking part ;o)


      Joeandtel <anonymous@disc ussions.microso ft.com> wrote in message
      news:A9C66CE5-9453-4950-AB8B-30BF8FD1C202@mi crosoft.com...[color=blue]
      > I have a form that asks for the size of a particular object. Sometimes the[/color]
      size is 4" X 8". The problem that arises is when the record is pulled back
      from a database to a textbox in a form; I get an error with HTML. I try and
      place the 4" X 8" into a text box, like <input type="text" name="size"
      value="4" X 8""> Is there something I can do in ASP to keep this from
      happening after the client receives the data?


      Comment

      • Bob Barrows [MVP]

        #4
        Re: Quotes from database to textbox

        Joeandtel wrote:[color=blue]
        > I have a form that asks for the size of a particular object.
        > Sometimes the size is 4" X 8". The problem that arises is when the
        > record is pulled back from a database to a textbox in a form; I get
        > an error with HTML. I try and place the 4" X 8" into a text box, like
        > <input type="text" name="size" value="4" X 8""> Is there something I
        > can do in ASP to keep this from happening after the client receives
        > the data?[/color]

        Double the quotes before writing the string into the value property. So it
        looks like this:

        <input type="text" name="size" value="4"" X 8""">

        Bob Barrows

        --
        Microsoft MVP -- ASP/ASP.NET
        Please reply to the newsgroup. The email account listed in my From
        header is my spam trap, so I don't check it very often. You will get a
        quicker response by posting to the newsgroup.


        Comment

        • Ray at

          #5
          Re: Quotes from database to textbox

          Are you feeling okay today Bob?

          Ray at work

          "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcom> wrote in message
          news:OxJKsCFEEH A.3016@TK2MSFTN GP11.phx.gbl...
          [color=blue]
          > Double the quotes before writing the string into the value property. So it
          > looks like this:
          >
          > <input type="text" name="size" value="4"" X 8""">[/color]


          Comment

          • Peter Foti

            #6
            Re: Quotes from database to textbox

            "Steven Burn" <nobody@PVT_i t-mate.co.uk> wrote in message
            news:OqvElBFEEH A.3256@TK2MSFTN GP09.phx.gbl...[color=blue]
            > Server.URLEncod e(TheString)
            >
            > I'm pretty sure there's an HTMLEncode one aswell but, never had a need to
            > know so can't say for sure.[/color]

            As the name would suggest, URLEncode is for encoding URL values, and
            HTMLEncode is for encoding regular HTML. They are different, so don't try
            to use URLEncode as a catch all. For example:


            <%
            ' Double the quotes to put a double quote in the string value
            val = "4"" X 8"""
            %>
            <input type="text" name="size" value="<%=Serve r.HTMLEncode(va l)%>">
            <input type="text" name="size" value="<%=Serve r.URLEncode(val )%>">

            The output above will look like this:

            <input type="text" name="size" value="4&quot; X 8&quot;">
            <input type="text" name="size" value="4%22+X+8 %22">

            Note, the first one will look correct in browsers... the 2nd will not.

            Regards,
            Peter Foti



            Comment

            • Bob Barrows [MVP]

              #7
              Re: Quotes from database to textbox

              Guess I had a brain fart.
              Of course doubling the quotes won't wotk. This is HTML, not vbscript ...

              However, using apostrophes for delimiters WILL work:
              <input type="text" name="size" value='4" X 8"'>

              Bob Barrows

              Ray at <%=sLocation% > [MVP] wrote:[color=blue]
              > Are you feeling okay today Bob?
              >
              > Ray at work
              >
              > "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcom> wrote in message
              > news:OxJKsCFEEH A.3016@TK2MSFTN GP11.phx.gbl...
              >[color=green]
              >> Double the quotes before writing the string into the value property.
              >> So it looks like this:
              >>
              >> <input type="text" name="size" value="4"" X 8""">[/color][/color]

              --
              Microsoft MVP -- ASP/ASP.NET
              Please reply to the newsgroup. The email account listed in my From
              header is my spam trap, so I don't check it very often. You will get a
              quicker response by posting to the newsgroup.


              Comment

              • Steven Burn

                #8
                Re: Quotes from database to textbox

                hehe, slight screwup on my part ;o)

                --
                Regards

                Steven Burn
                Ur I.T. Mate Group


                Keeping it FREE!

                Disclaimer:
                I know I'm probably wrong, I just like taking part ;o)


                Peter Foti <peter@Idontwan tnostinkingemai lfromyou.com> wrote in message
                news:105umtkqev 99e87@corp.supe rnews.com...[color=blue]
                > "Steven Burn" <nobody@PVT_i t-mate.co.uk> wrote in message
                > news:OqvElBFEEH A.3256@TK2MSFTN GP09.phx.gbl...[color=green]
                > > Server.URLEncod e(TheString)
                > >
                > > I'm pretty sure there's an HTMLEncode one aswell but, never had a need[/color][/color]
                to[color=blue][color=green]
                > > know so can't say for sure.[/color]
                >
                > As the name would suggest, URLEncode is for encoding URL values, and
                > HTMLEncode is for encoding regular HTML. They are different, so don't try
                > to use URLEncode as a catch all. For example:
                >
                >
                > <%
                > ' Double the quotes to put a double quote in the string value
                > val = "4"" X 8"""
                > %>
                > <input type="text" name="size" value="<%=Serve r.HTMLEncode(va l)%>">
                > <input type="text" name="size" value="<%=Serve r.URLEncode(val )%>">
                >
                > The output above will look like this:
                >
                > <input type="text" name="size" value="4&quot; X 8&quot;">
                > <input type="text" name="size" value="4%22+X+8 %22">
                >
                > Note, the first one will look correct in browsers... the 2nd will not.
                >
                > Regards,
                > Peter Foti
                >
                >
                >[/color]


                Comment

                Working...