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

The values entered are not posted back to the server

2 Answers 61 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Bruce
Top achievements
Rank 1
Bruce asked on 12 Nov 2010, 02:48 AM
Hi,

I got another problem when using Telerik RadFilter control. On the Web page, I added a button under the filter. When the button is clicked, I display the expressions in a string (similar to the Preview function, but I disabled the preview function in order to allow the user to edit the string). I tested and my function works fine, but got some problem with the value of the filter expressions.

From UI, I added an Contains expression, selected "PersonName" as the field, entered the value "test", and then clicked my button, it showed "(PersonName Contains '')"  without the string "test". I ran the code in DEBUG mode and found that the Value of the RadFilterContainsFilterExpression is NULL, the string "test" is not posted back to the server.

If I set the AllowFilterOnBlur property to false, all the values I entered are not posted back to the server. If I set the AllowFilterOnBlur property to true, only the last value I enterred is not posted back to the server.

How can I make the value posted to the server? Please help.

Many thanks

Bruce

2 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 17 Nov 2010, 03:01 PM
Hi Bruce,

The AllowFilterOnBlur property of the filter shows whether a postback will happen after a textbox from the filter loses focus. When you enter a value in the textbox and right after that you press the button, the button event is fired before the value of the RadFilterExpression is set. That is why you see null value there (or the old one). When the AllowFilterOnBlur is enabled and you click outside the box before hitting the button, a postback happens and the new value is set correctly. Then when pressing the button there will not be problems extracting the value.
One way to get the value entered by user directly on button click is to wire a client-side script to the button click event, and use the filter client-side API to get the value from the textbox.
Another approach is directly in the server code to call RadFilter1.FireApplyCommand(); This way filter expressions will be recreated and you should be able to extract the entered value.
protected void Button1_Click(object sender, EventArgs e)
        {
            RadFilter1.FireApplyCommand();
            string value = (RadFilter1.RootGroupItem.Expression.Expressions[0] as RadFilterContainsFilterExpression).Value;
        }

Let me know how this works for you and if you have any other questions.

Sincerely yours,
Marin
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Bruce
Top achievements
Rank 1
answered on 17 Nov 2010, 07:10 PM
Hi Marin,

It works perfectly. Thanks a lot.

Bruce
Tags
Filter
Asked by
Bruce
Top achievements
Rank 1
Answers by
Marin
Telerik team
Bruce
Top achievements
Rank 1
Share this question
or