URLEncode

Discussion in 'ASP .Net' started by djc, Jan 19, 2005.

  1. djc

    djc Guest

    1) I just recently used my own function which simply replaces cariage return
    / line feed characters with <br> tags for a large detail field before
    showing it via an asp.net page to preserve line breaks for web display.

    I have since come accross this URLEncode method. Is this something that I
    should have used for this instead?

    2) currently if you were to enter html tags into an input field on my
    asp.net web page the app will crash... I know this is by design for security
    reasons and if I don't require html tags being input I should just trap this
    error and handle it.

    What if I wanted to allow the html tags to be input? (URLEncode?).

    any info would be appreciated. Thanks.
     
    djc, Jan 19, 2005
    #1
    1. Advertising

  2. > I have since come accross this URLEncode method. Is this something that I
    > should have used for this instead?


    No. URLEncode is for URLs. HtmlEncode encodes strings to HTML-Friendly
    format.

    --
    HTH,

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

    "djc" <> wrote in message
    news:uAkGQSk$...
    > 1) I just recently used my own function which simply replaces cariage
    > return
    > / line feed characters with <br> tags for a large detail field before
    > showing it via an asp.net page to preserve line breaks for web display.
    >
    > I have since come accross this URLEncode method. Is this something that I
    > should have used for this instead?
    >
    > 2) currently if you were to enter html tags into an input field on my
    > asp.net web page the app will crash... I know this is by design for
    > security
    > reasons and if I don't require html tags being input I should just trap
    > this
    > error and handle it.
    >
    > What if I wanted to allow the html tags to be input? (URLEncode?).
    >
    > any info would be appreciated. Thanks.
    >
    >
     
    Kevin Spencer, Jan 19, 2005
    #2
    1. Advertising

  3. djc

    djc Guest

    thanks for the reply Spencer...
    1) My data is stored in 'normal' text in the database. So I can run this
    text through HtmlEncode before displaying it on the web page and the line
    breaks and spacing would be preserved (in html format)?

    2) If I wanted to allow a user, on the data input side of things, to be able
    to use html tags would HtmlEncode be used for that also? would the data then
    be stored in the database encoded rather than 'normal' text? (bad if a
    different non-browser front end were to need to display the data)
    Scenario 1: what if I need the data to be stored in the database in
    'normal' text but displayed literally when output to screen via browser
    (meaning show the html tags... like for showing code examples)?
    Scenario 2: what if I need the data to be stored in the database in
    'normal' text but when output to the browser have the browser actually
    interpret the html tags?

    any more info is greatly appreciated. Thanks again.

    "Kevin Spencer" <> wrote in message
    news:OQP3Sgk$...
    > > I have since come accross this URLEncode method. Is this something that

    I
    > > should have used for this instead?

    >
    > No. URLEncode is for URLs. HtmlEncode encodes strings to HTML-Friendly
    > format.
    >
    > --
    > HTH,
    >
    > Kevin Spencer
    > Microsoft MVP
    > .Net Developer
    > Neither a follower nor a lender be.
    >
    > "djc" <> wrote in message
    > news:uAkGQSk$...
    > > 1) I just recently used my own function which simply replaces cariage
    > > return
    > > / line feed characters with <br> tags for a large detail field before
    > > showing it via an asp.net page to preserve line breaks for web display.
    > >
    > > I have since come accross this URLEncode method. Is this something that

    I
    > > should have used for this instead?
    > >
    > > 2) currently if you were to enter html tags into an input field on my
    > > asp.net web page the app will crash... I know this is by design for
    > > security
    > > reasons and if I don't require html tags being input I should just trap
    > > this
    > > error and handle it.
    > >
    > > What if I wanted to allow the html tags to be input? (URLEncode?).
    > >
    > > any info would be appreciated. Thanks.
    > >
    > >

    >
    >
     
    djc, Jan 19, 2005
    #3
  4. See:

    http://msdn.microsoft.com/library/d...webhttpserverutilityclasshtmlencodetopic1.asp

    --
    HTH,

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

    "djc" <> wrote in message
    news:e3JwNpl$...
    > thanks for the reply Spencer...
    > 1) My data is stored in 'normal' text in the database. So I can run this
    > text through HtmlEncode before displaying it on the web page and the line
    > breaks and spacing would be preserved (in html format)?
    >
    > 2) If I wanted to allow a user, on the data input side of things, to be
    > able
    > to use html tags would HtmlEncode be used for that also? would the data
    > then
    > be stored in the database encoded rather than 'normal' text? (bad if a
    > different non-browser front end were to need to display the data)
    > Scenario 1: what if I need the data to be stored in the database in
    > 'normal' text but displayed literally when output to screen via browser
    > (meaning show the html tags... like for showing code examples)?
    > Scenario 2: what if I need the data to be stored in the database in
    > 'normal' text but when output to the browser have the browser actually
    > interpret the html tags?
    >
    > any more info is greatly appreciated. Thanks again.
    >
    > "Kevin Spencer" <> wrote in message
    > news:OQP3Sgk$...
    >> > I have since come accross this URLEncode method. Is this something that

    > I
    >> > should have used for this instead?

    >>
    >> No. URLEncode is for URLs. HtmlEncode encodes strings to HTML-Friendly
    >> format.
    >>
    >> --
    >> HTH,
    >>
    >> Kevin Spencer
    >> Microsoft MVP
    >> .Net Developer
    >> Neither a follower nor a lender be.
    >>
    >> "djc" <> wrote in message
    >> news:uAkGQSk$...
    >> > 1) I just recently used my own function which simply replaces cariage
    >> > return
    >> > / line feed characters with <br> tags for a large detail field before
    >> > showing it via an asp.net page to preserve line breaks for web display.
    >> >
    >> > I have since come accross this URLEncode method. Is this something that

    > I
    >> > should have used for this instead?
    >> >
    >> > 2) currently if you were to enter html tags into an input field on my
    >> > asp.net web page the app will crash... I know this is by design for
    >> > security
    >> > reasons and if I don't require html tags being input I should just trap
    >> > this
    >> > error and handle it.
    >> >
    >> > What if I wanted to allow the html tags to be input? (URLEncode?).
    >> >
    >> > any info would be appreciated. Thanks.
    >> >
    >> >

    >>
    >>

    >
    >
     
    Kevin Spencer, Jan 19, 2005
    #4
  5. djc

    djc Guest

    thanks, will do.

    "Kevin Spencer" <> wrote in message
    news:upuqwGn$...
    > See:
    >
    >

    http://msdn.microsoft.com/library/d...webhttpserverutilityclasshtmlencodetopic1.asp
    >
    > --
    > HTH,
    >
    > Kevin Spencer
    > Microsoft MVP
    > .Net Developer
    > Neither a follower nor a lender be.
    >
    > "djc" <> wrote in message
    > news:e3JwNpl$...
    > > thanks for the reply Spencer...
    > > 1) My data is stored in 'normal' text in the database. So I can run this
    > > text through HtmlEncode before displaying it on the web page and the

    line
    > > breaks and spacing would be preserved (in html format)?
    > >
    > > 2) If I wanted to allow a user, on the data input side of things, to be
    > > able
    > > to use html tags would HtmlEncode be used for that also? would the data
    > > then
    > > be stored in the database encoded rather than 'normal' text? (bad if a
    > > different non-browser front end were to need to display the data)
    > > Scenario 1: what if I need the data to be stored in the database in
    > > 'normal' text but displayed literally when output to screen via browser
    > > (meaning show the html tags... like for showing code examples)?
    > > Scenario 2: what if I need the data to be stored in the database in
    > > 'normal' text but when output to the browser have the browser actually
    > > interpret the html tags?
    > >
    > > any more info is greatly appreciated. Thanks again.
    > >
    > > "Kevin Spencer" <> wrote in message
    > > news:OQP3Sgk$...
    > >> > I have since come accross this URLEncode method. Is this something

    that
    > > I
    > >> > should have used for this instead?
    > >>
    > >> No. URLEncode is for URLs. HtmlEncode encodes strings to HTML-Friendly
    > >> format.
    > >>
    > >> --
    > >> HTH,
    > >>
    > >> Kevin Spencer
    > >> Microsoft MVP
    > >> .Net Developer
    > >> Neither a follower nor a lender be.
    > >>
    > >> "djc" <> wrote in message
    > >> news:uAkGQSk$...
    > >> > 1) I just recently used my own function which simply replaces cariage
    > >> > return
    > >> > / line feed characters with <br> tags for a large detail field before
    > >> > showing it via an asp.net page to preserve line breaks for web

    display.
    > >> >
    > >> > I have since come accross this URLEncode method. Is this something

    that
    > > I
    > >> > should have used for this instead?
    > >> >
    > >> > 2) currently if you were to enter html tags into an input field on my
    > >> > asp.net web page the app will crash... I know this is by design for
    > >> > security
    > >> > reasons and if I don't require html tags being input I should just

    trap
    > >> > this
    > >> > error and handle it.
    > >> >
    > >> > What if I wanted to allow the html tags to be input? (URLEncode?).
    > >> >
    > >> > any info would be appreciated. Thanks.
    > >> >
    > >> >
    > >>
    > >>

    > >
    > >

    >
    >
     
    djc, Jan 20, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Russ

    URLEncode

    Russ, Aug 4, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    2,940
    mikeb
    Aug 4, 2003
  2. vtreddy

    Datagrid HYperlinnk column URLEncode

    vtreddy, Oct 24, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    396
    vtreddy
    Oct 24, 2003
  3. vtreddy

    URLEncode Problem from ASP.NET

    vtreddy, Oct 25, 2003, in forum: ASP .Net
    Replies:
    5
    Views:
    5,694
    vtreddy
    Oct 25, 2003
  4. Andreas Klemt
    Replies:
    4
    Views:
    10,310
    mikeb
    Jan 22, 2004
  5. Dario Sala
    Replies:
    1
    Views:
    3,810
    Karl Seguin
    Nov 15, 2004
Loading...

Share This Page