Textbox Postbax causing Window to flash & close

2 posts, 0 answers
  1. David
    David avatar
    1 posts
    Member since:
    Nov 2011

    Posted 09 Nov 2011 Link to this post

    Good day;

    It seems that the postback texchanged event of a radinput(textbox) control interferes with opening a radwindow as a popup. The net effect is that the window (dialog) will open and close automatically.

    Unfortunatley; copyright laws prevent me from posting the source but I will do my best to explain it correctly.

    I'm working on a user control composed of:
            - RADINPUT(TEXTBOX) (autopostback off)
            - ASP IMAGE BUTTON
            - RAD WINDOW object, set to modal, with the navigateurl set to "dialog.aspx", linked to the ASPIMAGEBUTTON via OpenerElementID

     
    The Popup page, say dialog.aspx is composed mainly of:
        - Textbox to enter search value
        - asp image button - triggers off the search
        - radgrid to display the results

    The objective of the control is to provide a text thats tied to a search dialog. If the user doesnt know the value they can search for it via the dialog, select the value they want and bring it back to the text box.

        Everything works well and is awesome. Except, a new requirement came in. God wants whatever text that users type in the textbox of the user control come across to the search dialog window and be defaulted into the textbox for the search. Perfectly reasonable.

    In order to achieve this I added a querystring value to carry the value from the textbox into the dialog.aspx. In order to modify the navigateurl of the radwindow I added codebehind to the textchanged event of the user control textbox and turned on its autopostback. Mostly it works....however.....there is one scenario where I believe the postback from the textbox control is interfering with the rad windows opening.

    The scenario is:
        Enter text into the textbox; without tabing out or hitting enter; click on the image button.

    The action above should cause the following in order:

    1. Run textbox.textchanged event and Update the navigateurl of the radwindow.
    2. Open the rad window dialog.

    What actually happens is that the radwindow opens and closes. If I click on the image to open it again, it seems the navigateurl did not get updated by the textbox event. In other words, it seems that clicking on the button while the focus is still on the textbox causes the postback from the textbox to get shorted and the opening of the dialog to be aborted.

    I have managed to work around this by turning off the textbox's autopostback and adding some client side code. However, if in the future we need to activate the autopostback for the textcontrol in order to manage the textchanged event on any asp that implements it the problem will resurface.

    Thanks in advance for the help;
    David

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4609 posts

    Posted 11 Nov 2011 Link to this post

    Hi David,

    I am not sure exactly how you have set this control up, but i advise that you take a look at the following articles that are related to the functionality you are using in the light of my comments with them:

    opening a RadWindow from the server - I advise that you avoid using the OpenerElementId property, especially in user controls and other INaming containers, as it expects a client ID of an HTML element which is subject to change by the framework. This will also (I believe) remove the issue with the flicker, as it seems that now the window tries to open due to this property, but the postback prevents this. The handler the RadWindow attaches to this element usually results in preventing it from posting back, which may also be e part of your issue

    RadWindow's Client-side API - using JavaScript to change the URL of the RadWindow would be much faster than performing a full postback, especially once the site is deployed this will result in a performance gain and smoother user experience

    Passing values to a RadWindow - this is an alternative to using the querystring as it would allow you to avoid a page reload in the RadWindow. It will require some JavaScript and perhaps migrating some functionality to JavaScript in the search page as well. You can see it live in this demo as well. An alternative is to directly call a function in the dialog and pass the information as a parameter to it.

    I also tried your scenario and the text-changed event seems to be fired correctly on my end, yet my test page is perhaps quite far from your actual setup and something else there may be interfering. I am attaching it here as a reference and you can see a video from my test here.


    All the best,
    Marin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top