RadWindow callback doPostBack and Ajax

9 posts, 0 answers
  1. Rod
    Rod avatar
    23 posts
    Member since:
    Aug 2007

    Posted 04 Dec 2008 Link to this post

    Hi all,

    I'm using a radconfirm window on a webform and when the user clicks Ok, I do a __doPostBack() to perform some server operations.

    Here's my javascript:
    function promptConfirm(id)
    {
        var callBackFn = function(arg)
        {
            if (arg == true)
                __doPostBack("yesButton", id);
        }
        radconfirm("Did you print the confirmation report(s)?", callBackFn, 330, 100);
    }

    In the code behind, I update a field in the database and rebind a grid on the same page.
    I'm trying to write it so the grid rebinds during postback, but using ajax, so the user can't see the whole page flicker.

    Any help would be appreciated.

    Rod

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Dec 2008 Link to this post

    Hi Rod,

    Add AjaxManager on page and configure that as shown below. Then you can call the AjaxRequest from client side only if clicked on Ok button of RadConfirm, which will execute RadAjaxManager1_AjaxRequest.

    ASPX:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"   
                onajaxrequest="RadAjaxManager1_AjaxRequest">  
                <AjaxSettings> 
                    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">  
                        <UpdatedControls> 
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                        </UpdatedControls> 
                    </telerik:AjaxSetting> 
                </AjaxSettings> 
    </telerik:RadAjaxManager> 
     
     
    <script type="text/javascript">  
    function promptConfirm1()  
    {  
        var callBackFn1 = function(arg)  
        {  
            if (arg == true)  
               $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest();  
        }  
        radconfirm("Did you print the confirmation report(s)?", callBackFn1, 330, 100);  
    }  
    </script> 

    CS:
    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)  
    {  
        RadGrid1.MasterTableView.SortExpressions.Clear();  
        RadGrid1.MasterTableView.GroupByExpressions.Clear();  
        RadGrid1.Rebind();  


    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Rod
    Rod avatar
    23 posts
    Member since:
    Aug 2007

    Posted 05 Dec 2008 Link to this post

    Princy,

    Thanks for the prompt reply.

    I implemented your suggestion, but I'm now getting an "'nul' is null or not an object" runtime error in the call back function when using $find.

    When debugging, the javascript looks like this:
    function promptConfirm(id)
            {
                var callBackFn = function(arg)
                {
                    if (arg == true)
                        $find("").ajaxRequest();
                        //__doPostBack("yesButton", id);
                }
                radconfirm("Did you print the confirmation report(s)?", callBackFn, 330, 100);
            }

    This web page has a Master Page as well. I'm not sure if that has anything to do with it, but if you have any ideas, I'd appreciate it.

    Thanks,

    Rod



  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 08 Dec 2008 Link to this post

    Hello Rod,

    Does the RadAjaxManager placed on the MasterPage in your scenario? If yes, the control should be found by using GetCurrent method from the ContentPage.

    For example:

    $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("");

    For more information on this matter please review the following help topic.

    All the best,
    Maria Ilieva
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. HananJ
    HananJ avatar
    15 posts
    Member since:
    Nov 2010

    Posted 22 Dec 2010 Link to this post

    Hello Telerik Team,
    I have same issue, but i tried the solution suggested above, but it didn't work for me..
    I do have A RadComoBox which is supposed on its ClientSelectedIndex to set a hidden field to the its selected value, here is the code:

    <script type="text/javascript">
     
     
            function DoPostBack(Arg) {
                if (event.propertyName.toLowerCase() == 'value'.toLowerCase()) {
                    window.document.forms[0].target = '_self';
                    __doPostBack('__Page', Arg);
                }
            }
     
     
            function SupplierSelectedIndexChanged(sender, eventArgs) {
                var item = eventArgs.get_item();
                var rcbCountry = $find("<%= rcbCountry.ClientID %>");
                if (rcbCountry.get_enabled()) {
                    document.getElementById("<%= hiddenSupplierId.ClientID %>").value = item.get_value();
                }
            }
    </script>



    <telerik:radajaxmanager runat="server" id="RadAjaxManager1">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="rcbCountry">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="pnlSource" LoadingPanelID="RadAjaxLoadingPanel1"/>
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="rcbSuppliers">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="pnlSource" LoadingPanelID="RadAjaxLoadingPanel1"/>
                        <telerik:AjaxUpdatedControl ControlID="rdoUnitsOfMesurement"/>
                        <telerik:AjaxUpdatedControl ControlID="rdoUnits"/>
                        <telerik:AjaxUpdatedControl ControlID="txtQuantity"/>
                        <telerik:AjaxUpdatedControl ControlID="hiddenSupplierId"/>
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="rcbBrands">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="pnlSource" LoadingPanelID="RadAjaxLoadingPanel1"/>
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="rcbSubBrands">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="pnlSource" LoadingPanelID="RadAjaxLoadingPanel1"/>
                    </UpdatedControls>
                </telerik:AjaxSetting>     
            </AjaxSettings>
        </telerik:radajaxmanager>
     
     
    <asp:Panel runat="server" ID="pnlSource">
                        <table width="100%" cellpadding="0" cellspacing="3">
                            <tr>
                                        <td align="right" valign="top" style="width: 168px">
                                            <asp:Label ID="lblCountry" runat="server"></asp:Label>
                                        </td>
                                        <td>
                                            <table width="100%" cellpadding="0" cellspacing="0">
                                                <tr>
                                                    <td>
                                                        <telerik:radcombobox runat="server" id="rcbCountry" autopostback="true" width="195px"
                                                            tabindex="3" onselectedindexchanged="rcbCountry_SelectedIndexChanged" causesvalidation="false">
                                                        </telerik:radcombobox>
                                                          
                                                        <asp:CustomValidator ID="customValidatorCountryIcon" runat="server" ClientValidationFunction="ValidateCountry"
                                                            Display="Dynamic">
                                                            <img alt="" src="/Include/Img/icon_error.gif" />   
                                                        </asp:CustomValidator>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:CustomValidator ID="customValidatorCountry" runat="server" ClientValidationFunction="ValidateCountry"
                                                            Display="Dynamic">
                                                        </asp:CustomValidator>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                            <tr id="trSupplier" runat="server">
                                        <td align="right" valign="top" style="width: 168px">
                                            <asp:Label ID="lblSupplier" runat="server"></asp:Label>
                                        </td>
                                        <td>
                                            <table width="100%" cellpadding="0" cellspacing="0">
                                                <tr>
                                                    <td>
                                                        <telerik:radcombobox runat="server" id="rcbSuppliers" autopostback="true" width="195px"
                                                            tabindex="5" onselectedindexchanged="rcbSuppliers_SelectedIndexChanged" causesvalidation="false"
                                                            allowcustomtext="true" filter="Contains" OnClientSelectedIndexChanged="SupplierSelectedIndexChanged" >
                                                        </telerik:radcombobox>
                                                          
                                                        <asp:CustomValidator ID="customValidatorSupplierName2" runat="server" ClientValidationFunction="ValidateSupplier"
                                                            Display="Dynamic">
                                                            <img alt="" src="/Include/Img/icon_error.gif" />   
                                                        </asp:CustomValidator>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:CustomValidator ID="customValidatorSupplierName" runat="server" ClientValidationFunction="ValidateSupplier"
                                                            Display="Dynamic">
                                                        </asp:CustomValidator>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                            <tr id="trBrand" runat="server">
                                        <td align="right" valign="top" style="width: 168px">
                                            <asp:Label ID="lblBrand" runat="server"></asp:Label>
                                        </td>
                                        <td>
                                            <table width="100%" cellpadding="0" cellspacing="0">
                                                <tr>
                                                    <td>
                                                        <telerik:radcombobox runat="server" id="rcbBrands" autopostback="true" width="195px"
                                                            tabindex="6" onselectedindexchanged="rcbBrands_SelectedIndexChanged" causesvalidation="false"
                                                            allowcustomtext="true" filter="Contains">
                                                        </telerik:radcombobox>
                                                          
                                                        <asp:CustomValidator ID="customValidatorBrandIcon" runat="server" ClientValidationFunction="ValidateBrand"
                                                            Display="Dynamic">
                                                            <img alt="" src="/Include/Img/icon_error.gif" />   
                                                        </asp:CustomValidator>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:CustomValidator ID="customValidatorBrand" runat="server" ClientValidationFunction="ValidateBrand"
                                                            Display="Dynamic">
                                                        </asp:CustomValidator>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                            <tr id="trSubbrand" runat="server">
                                        <td align="right" valign="top" style="width: 168px">
                                            <asp:Label ID="lblSubBrand" runat="server" ></asp:Label>
                                        </td>
                                        <td>
                                            <table width="100%" cellpadding="0" cellspacing="0">
                                                <tr>
                                                    <td>
                                                        <telerik:radcombobox runat="server" id="rcbSubBrands" autopostback="true" width="195px"
                                                            tabindex="7" onselectedindexchanged="rcbSubBrands_SelectedIndexChanged" causesvalidation="false"
                                                            allowcustomtext="true" filter="Contains">
                                                        </telerik:radcombobox>
                                                        <asp:CustomValidator ID="customValidatorSubBrand" runat="server" ClientValidationFunction="ValidateSubBrand"
                                                            Display="None">
                                                        </asp:CustomValidator>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                        </table>
                     </asp:Panel>

    if (Page.IsPostBack)
                {
                    eventArg = Request["__EVENTARGUMENT"];
                    if (eventArg.Equals("hiddenSupplierId_ValueChanged"))
                        hiddenSupplierId_ValueChanged();
                }

    When any item selected from suppliers, The page flickers like Postback, I know it is postabck but want the Ajax to do any help here..!


  7. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 23 Dec 2010 Link to this post

    Hello Rod,

    Could you please ensure that you have RadScriptManager in the very top of the Page where the RadAjaxManager is placed.

    Greetings,
    Maria Ilieva
    the Telerik team
    Browse the vast support resources we have to jump start 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.
  8. HananJ
    HananJ avatar
    15 posts
    Member since:
    Nov 2010

    Posted 23 Dec 2010 Link to this post

    I justed wanted to explain my issue, if i want to make a usercontrol send data to another user control, should i have to put a RadAjaxManager on the parent of both userControl1 (uctrfoodAddEdit)& userControl2 (uctrfoodLocalize) as shown below:

       <telerik:radajaxmanager runat="server" id="RadAjaxManager1">
    <AjaxSettings>
    <telerik:AjaxSetting AjaxControlID="uctrfoodAddEdit">
    <UpdatedControls>
    <telerik:AjaxUpdatedControl ControlID="uctrfoodLocalize"/>
    </UpdatedControls>
    </telerik:AjaxSetting>
    </AjaxSettings>
    </telerik:radajaxmanager>


    .And add the following to userControl1 (uctrfoodAddEdit):
    <telerik:RadAjaxManagerProxy  runat="server" id="radAjaxManagerProxy1">
    <AjaxSettings>
    <telerik:AjaxSetting AjaxControlID="rcbCountry">
    <UpdatedControls>
    <telerik:AjaxUpdatedControl ControlID="pnlSource" LoadingPanelID="RadAjaxLoadingPanel1"/>
    </UpdatedControls>
    </telerik:AjaxSetting>
    <telerik:AjaxSetting AjaxControlID="rcbSuppliers">
    <UpdatedControls>
    <telerik:AjaxUpdatedControl ControlID="pnlSource" LoadingPanelID="RadAjaxLoadingPanel1"/>
    <telerik:AjaxUpdatedControl ControlID="rdoUnitsOfMesurement"/>
    <telerik:AjaxUpdatedControl ControlID="rdoUnits"/>
    <telerik:AjaxUpdatedControl ControlID="txtQuantity"/>
    <telerik:AjaxUpdatedControl ControlID="hiddenSupplierId"/>
    </UpdatedControls>
    </telerik:AjaxSetting>
    <telerik:AjaxSetting AjaxControlID="rcbBrands">
    <UpdatedControls>
    <telerik:AjaxUpdatedControl ControlID="pnlSource" LoadingPanelID="RadAjaxLoadingPanel1"/>
    </UpdatedControls>
    </telerik:AjaxSetting>
    <telerik:AjaxSetting AjaxControlID="rcbSubBrands">
    <UpdatedControls>
    <telerik:AjaxUpdatedControl ControlID="pnlSource" LoadingPanelID="RadAjaxLoadingPanel1"/>
    </UpdatedControls>
    </telerik:AjaxSetting>
    </AjaxSettings>
    </telerik:RadAjaxManagerProxy >
    <telerik:radajaxloadingpanel id="RadAjaxLoadingPanel1" runat="server">
    </telerik:radajaxloadingpanel>



  9. HananJ
    HananJ avatar
    15 posts
    Member since:
    Nov 2010

    Posted 23 Dec 2010 Link to this post

    in addition to the above, Where i have to place the RadScriptManager in the parent page (aspx) or in user control that sends info to user control2.
  10. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 28 Dec 2010 Link to this post

    Hi Rod,

    The best practice is to place the RadScriptManager on the main page, just after the opening <form> tag. And just after it place the RadAjaxManager declaration. Then in the user controls, add RadAjaxManagerProxy controls to add the ajax setting.
     
    Kind regards,
    Iana
    the Telerik team
    Browse the vast support resources we have to jump start 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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017