The values entered are not posted back to the server

3 posts, 0 answers
  1. Bruce
    Bruce avatar
    12 posts
    Member since:
    Oct 2010

    Posted 11 Nov 2010 Link to this post

    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. Marin
    Admin
    Marin avatar
    1045 posts

    Posted 17 Nov 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bruce
    Bruce avatar
    12 posts
    Member since:
    Oct 2010

    Posted 17 Nov 2010 Link to this post

    Hi Marin,

    It works perfectly. Thanks a lot.

    Bruce
Back to Top