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

"Refresh" control on parent page from RadWindow using onclientclose

3 Answers 63 Views
Window
This is a migrated thread and some comments may be shown as answers.
Geoff
Top achievements
Rank 1
Geoff asked on 13 Nov 2012, 05:28 PM
 I have a cart radbutton with a numeric total that is it's own control that sits on Default.aspx. The numeric total is called by a server side method.

I have a radwindow control that has the ability to add items to that cart.

Onclientclose of the radwindow, I need to find a way to refresh or postback that radbutton control to update my total cart items.

I DO NOT want the entire page to postback.

How can I accomplish this?

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 14 Nov 2012, 05:57 AM
Hi Geoff,

Here is the sample code that I tried to achieve your scenario.

ASPX:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadWindow1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="div1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadWindow ID="RadWindow1" runat="server" OnClientClose="OnClientClose" ...  >
</telerik:RadWindow>
<div id="div1">
    <telerik:RadButton ID="RadButton1" runat="server" OnClick="RadButton1_Click" ... >
    </telerik:RadButton>
</div>

JS:
<script type="text/javascript">
    function OnClientClose(sender, args) {
        __doPostBack("<%=RadButton1.UniqueID %>", "");
    }
</script>

Hope this helps.

Regards,
Princy.
0
rdmptn
Top achievements
Rank 1
answered on 14 Nov 2012, 08:20 AM
RadWindow does not postback. The button does, so your ajax initiator should be the button, not the window:
<telerik:AjaxSetting AjaxControlID="RadButton1">
    <UpdatedControls>
        <telerik:AjaxUpdatedControl ControlID="div1" />
    </UpdatedControls>
</telerik:AjaxSetting>

0
Geoff
Top achievements
Rank 1
answered on 14 Nov 2012, 07:40 PM
Thanks for you response. I did dabble with it a little bit, but I instead took this approach.

From my radwindow control, I used the onclientclosed to point to a js function that exists on cartbutton control.

Radwindow control
function OnClientClose(sender, args) {
 
    refreshCartCount(null);
 
}

Cart Control
    <script type="text/javascript">

        function refreshCartCount() {
            $find("<%= btnCartAjaxPanel.ClientID %>").ajaxRequestWithTarget("<%=btnCartAjaxPanel.UniqueID %>", "");
                
        }

    </script>

Ajax Panell with button
<telerik:RadAjaxPanel ID="btnCartAjaxPanel" runat="server" OnAjaxRequest="btnCartAjaxPanel_AjaxRequest"></telerik:RadAjaxPanel>
 
        <telerik:RadButton ID="btnCart" runat="server" Text="CART" OnClick="btnCart_Click"
            BackColor="White" CssClass="shoppingRadButton">
        </telerik:RadButton>

C#
protected void btnCartAjaxPanel_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
    RefreshCartItemCount();
}

This seems like a much cleaner approach. More Code/Markup, but cleaner.
Tags
Window
Asked by
Geoff
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
rdmptn
Top achievements
Rank 1
Geoff
Top achievements
Rank 1
Share this question
or