Search code examples
c#asp.nettelerikrad

Calling C# code from a Telerik radconfirm


Is it possible to Call C# code from a Telerik radconfirm? I can make it call Javascript, but no server side code. I want the user to click a button which gives them a popupbox (radconfirm). With the radconfirm - if the user selects "yes" the c# code will be executed, if they click "cancel" no code will be executed

<asp:Button 
                    ID="button1" 
                    runat="server" 
                    CssClass="resetOk" 
                    Text="OK"
                    OnClientClick="radconfirm('<h3 style=\'color: #333399;\'>
                    Are you sure you want to reset this budget?</h3>',confirmCallBackFn,
                    330, 100,null,'Confirm Reset'); return false;"
/>

Solution

  • You have (at least) two options for calling server code from a RadConfirm (or any JavaScript event, for that matter). In the client-side event handler, either:

    • A) Using Microsoft AJAX to perform a "sneaky postback" and process server-side code
    • B) Use jQuery (or MSFT AJAX) to call a web service that executes your code

    Option B is superior to Option A because it avoids the ASP.NET Page Lifecycle and is a much lighter, faster way to execute server code in response to a client event. Only use Option A if the code you're executing on the server needs to update ASP.NET server controls on the page.

    References to help you with either option:

    Calling ASP.NET web services with jQuery

    Executing AJAX PostBack with RadAjaxManager from JavaScript