This is a migrated thread and some comments may be shown as answers.

[Solved] Special characters in filtering

1 Answer 189 Views
Grid
This is a migrated thread and some comments may be shown as answers.
unnikkannan m
Top achievements
Rank 1
unnikkannan m asked on 10 Sep 2009, 09:24 AM
Hi,

    In the demo while we are entering the special characters in the filtering textbox it throws error and redirect to the link
http://demos.telerik.com/ErrorPageResources/error.aspx?aspxerrorpath=/aspnet-ajax/grid/examples/generalfeatures/filtering/defaultcs.aspx


How to avoid the special characters in the filtering textbox??


Unni

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 11 Sep 2009, 09:56 AM
Hi Unni,

I tried follwing appraoch in order to prevent the special characters entering in filer textbox.

CS:
 
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    if (e.Item is GridFilteringItem) 
    { 
        GridFilteringItem fItem = (GridFilteringItem)e.Item; 
        foreach (GridColumn col in RadGrid1.MasterTableView.Columns) 
        { 
            (fItem[col.UniqueName].Controls[0] as TextBox).Attributes.Add("onkeyup""CheckSpecial(this, event)"); 
        } 
    } 

JavaScript:
 
<script type="text/javascript"
function CheckSpecial(text,e) 
    var regx, flg;   
    regx = /[^0-9a-zA-Z'' ]/   
    flg = regx.test(text.value);   
    if (flg) 
    {   
        var val=text.value; 
        val=val.substr(0,(val.length)-1) 
        text.value=val;       
    }   
</script> 

-Shinu.
Tags
Grid
Asked by
unnikkannan m
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or