Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5994349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:48:20+00:00 2026-05-22T23:48:20+00:00

I use Asp.Net 4, C# and MS SQL. For my website I use MS

  • 0

I use Asp.Net 4, C# and MS SQL.

For my website I use MS default solution for preventing Cross-Site Scripting.

I’m also used to ENCODE all User’s Inputs in my logic so that this data can be stored ENCODED in my Data Base.

At the moment I’m using a GridView to do some basic CRUD operation but I’m facing a problem.

  • CREATE: User can insert any inputs, my logic will ENCODE and save on Data Base.
  • READ: The GridView can display the User’s Input from Data Base in a “Label” the result is DECODED thanks to the Properties for the Field “HtmlEnscape True or False.
  • UPDATE: Here my problem! At time of editing the TextBox show up the User input from the DataBase Encoded (in this way was saved) but I would need to DECODED again to show it up to the User so can be edited in a friendly way and resaved.

My questions:
– How to do it?
– Because I have many TextBox in many pages in my application, how to centralize this behavior?

Thanks guys for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:48:21+00:00Added an answer on May 22, 2026 at 11:48 pm

    Firstly I would say that you should never encode before storing in a database. You encode at the point of output – before you put it in a text box, or a grid or wherever.

    This has a few advantages;

    1. You’re format agnostic – you can take your data and put it as HTML, XML, JSON or whatever because you haven’t locked yourself to a single format when storing.
    2. It makes search easier, if you’re searching those fields.
    3. If there is a bug in the Encode function you’re using you may end up storing unsafe values. By encoding at the point of output you could replace your encoder with a non-buggy one, or one using a blacklist rather than a whitelist without having to go through all your data, pulling it out, decoding it and re-encoding it.

    In the case of textbox the actual encoding depends on the type of textbox – a single line text box is attribute encoded, a multiline text box is HTML encoded, and using the text property of the asp.net textbox control encodes for you, using the correct method.

    By storing “raw” HTML you remove the need to decode because the controls are encoding automatically for you, there is nothing for you to centralise.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Link I'm using ASP.NET with C# and trying to use linq to sql to
I am using AdoNetAppender (SQL server) in my asp.net application and would like use
I use C#, IIS, ASP.NET, SQL Server. Is there a third-party platform I can
We're using ELMAH for error logging in our ASP.NET application. We use the SQL
I have an ASP.Net 4.0 website which uses SQL Server CE and EF code-first
We have an ASP.NET website and an SQL database hosted in US. Whenever I
My website/application is in ASP.NET. I use the traditional Session object when people connect
I'm in the process up changing a single SQL DB website (ASP.NET/VB.NET) into a
For my asp.net website with forms authentication, I will use Windows integrated security to
I have a process in a website (Asp.net 3.5 using Linq-to-Sql for data access)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.