Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Filter > remove spaces in search criteria

Not answered remove spaces in search criteria

Feed from this thread
  • Robin avatar

    Posted on Jan 23, 2012 (permalink)

    I needed to be able to trim leading & trailing spaces that may have been inadvertently entered by the user as part of their search criteria. I tried to find documentation on this to no avail. If there's a better way to do it, please let me know. 

    Until then, this is what I did...
    I used a separate button to execute the search. The onclick of that button fires this method:

       protected void FilterData(object sender, EventArgs e)
        {
            LoopThruFilterControls(rfPortfolios.Controls);
            rfPortfolios.FireApplyCommand();
        }



    And LoopThruFilterControls looks like this:
        private void LoopThruFilterControls(ControlCollection cc)
         {
            for (int i = 0; i < cc.Count; i++)
            {
    string controlType = cc[i].GetType().Name;
    if(controlType.Equals("TextBox", StringComparison.CurrentCultureIgnoreCase))
    {
    TextBox tmp = (TextBox)cc[i];
                    ((TextBox)cc[i]).Text = tmp.Text.Trim();
                    }
                    LoopThruFilterControls(cc[i].Controls);
            }
        }

    Reply

  • Posted on Jan 24, 2012 (permalink)

    Hello,

    I have tried the following code after accessing the TextBox and it worked as expected.
    C#:
     string t= textbox.Text;
     string s = t.Trim();
     text.Text = s;

    Hope it helps.

    Thanks,
    Princy.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Filter > remove spaces in search criteria
Related resources for "remove spaces in search criteria"

ASP.NET Filter Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]