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

RadWindow callback doPostBack and Ajax

8 Answers 395 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Rod
Top achievements
Rank 1
Rod asked on 05 Dec 2008, 04:42 AM
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

8 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Dec 2008, 08:31 AM
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.
0
Rod
Top achievements
Rank 1
answered on 05 Dec 2008, 05:58 PM
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



0
Maria Ilieva
Telerik team
answered on 08 Dec 2008, 12:21 PM
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.
0
HananJ
Top achievements
Rank 1
answered on 22 Dec 2010, 09:23 AM
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..!


0
Maria Ilieva
Telerik team
answered on 23 Dec 2010, 03:57 PM
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.
0
HananJ
Top achievements
Rank 1
answered on 23 Dec 2010, 04:09 PM
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>



0
HananJ
Top achievements
Rank 1
answered on 23 Dec 2010, 04:12 PM
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.
0
Iana Tsolova
Telerik team
answered on 28 Dec 2010, 10:07 AM
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.
Tags
Ajax
Asked by
Rod
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Rod
Top achievements
Rank 1
Maria Ilieva
Telerik team
HananJ
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or