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

  • SEARCH
  • Home
  • 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 8133595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:39:48+00:00 2026-06-06T09:39:48+00:00

I have an existing project, so I need a solid way of cleaning/checking user

  • 0

I have an existing project, so I need a solid way of cleaning/checking user input, globally.

I have a Master page (parent) that has the form tag, and the “children” pages contains the form elements with the post back commands, insert/update/delete to database etc.

Using C# only – Is there some way I can globally intercept the postbacks before post runs through the child page?

And is it possible to check if it’s a textbox/checkbox/radioButton etc. to manipulate cleaning of user input differently?

  • 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-06-06T09:39:50+00:00Added an answer on June 6, 2026 at 9:39 am

    This is what I did to get it working.

    • Override the OnInit event on my MasterPage

    • Disable the ReadOnly for my Request collection so it is settable.

    • Loop through Posted .Net Controls, Sanitize value and set new value.

    • Re-enable ReadOnly.

    Works great globally and saved me days of manual labour 🙂

    protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
    
            if (IsPostBack)
            {
                var fCollection = (NameValueCollection)Request.GetType().GetField("_form", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(Request);
                PropertyInfo oReadable = fCollection.GetType().GetProperty("IsReadOnly", BindingFlags.NonPublic | BindingFlags.Instance);
                oReadable.SetValue(fCollection, false, null);
    
                foreach (string s in Request.Params.Keys)
                {
                    var pCtrl = Page.FindControl(s);
    
                    //Sanitize the posted values (TextHandler.SimpleSanitize is my own static method)
                    if (pCtrl != null) fCollection[s] = TextHandler.SimpleSanitize(fCollection[s]);
                }
    
                oReadable.SetValue(fCollection, true, null);
    
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an existing project that builds fine using my IDE. I'd like to
I have an existing project that consumes web services. One was added as a
I have an existing iphone project with a UITabBar. Now I need styled text
I have an existing ASP.Net MVC project that is using entities / repositories in
We have an existing java-based heavyweight project that needed an interactive script interpreter. After
I have an existing project that uses @Override on methods that override interface methods,
I have an existing Grails project that I am upgrading to a new version.
I have a current existing project repository that has a lot of code that
I have an existing Java project in Netbeans that uses Swing and I would
We already have an existing MSI Installer (web deployment project - .vdproj) that we

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.