views:

153

answers:

3

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;"
/>
A: 

You can add a RadAjaxManager on the page and then just make an Ajax request in your confirmCallBackFn. This will raise an event on the server and you will be able to execute server code without needing to update any controls on the page - see the telerik help for the implementation details.

lingvomir
A: 

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

Todd
A: 

Hi from what I understand you want to block the execution of the onclick like you would be able to do with a standard confirm popup there is a knowledge base article on the telerik site: Block the execution thread with radconfirm

Sean Molam