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

Filter giving error if we enter ';'

2 Answers 34 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raj J
Top achievements
Rank 1
Raj J asked on 23 Mar 2010, 11:08 AM
Hi,

   Filter is giving error when we enter ';' (semo colon) in the filter control. Please send me the solution asap.

thanks,
Raj

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Mar 2010, 11:26 AM
Hello Raj,

You can prevent the user from typing the special character. Try the following code in order to achieve this.

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""Backslash(this, event)");    
        }    
    }    
}   

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

Also refer the following forum link, that might help in this issue.
Block special characaters in filtercolumn in grid

Thanks,
Princy.
0
Raj J
Top achievements
Rank 1
answered on 23 Mar 2010, 11:31 AM
Thanks for the quick reply, But my case is user is copy and pasting a line where the line contains the ';'.

Thanks,
Raj
Tags
Grid
Asked by
Raj J
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Raj J
Top achievements
Rank 1
Share this question
or