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

tool bar confirm dialog

1 Answer 40 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Kris
Top achievements
Rank 1
Kris asked on 23 Jul 2012, 07:03 PM
I have a custom control "toolbar" my page and I have created a confirm dialog for one of the toolbar button. I need to hook-up some server side code from the javascript. Is is possible with telerik toolbar ? Thanks in advance. 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Jul 2012, 05:39 AM
Hi Kris,

To hook-up some server side code from the javascript You need a postback. You can do this by placing an invisible server button on your page and then in the JavaScript callback function of radconfirm to invoke the "click" event of the button which will cause a postback. Then, in the event handler of the button you can perform the server side actions. Try the following code snippets.. 

ASPX:
<asp:Button ID="Button1" runat="server" CssClass="buttons"  Text="Button" onclick="Button1_Click" />

CSS:
<style type="text/css">
 .buttons
 {
  display:none;
 }
</style>

Javascript:
<script type="text/javascript">
 function OnClientButtonClicked()
 {
  radconfirm('Are you sure!?', confirmCallBackFn);
 }
 function confirmCallBackFn(arg)
 {
  if (arg == true)
  {
   document.getElementById("Button1").click();
  }
 }
</script>

C#:
protected void Button1_Click(object sender, EventArgs e)
{
 // Your Code
}

Thanks,
Princy.
Tags
ToolBar
Asked by
Kris
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or