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

Codebehind javascript confirm box

1 Answer 105 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
sreedhar ambati
Top achievements
Rank 1
sreedhar ambati asked on 15 Apr 2011, 02:12 PM
HI

I have 2 textboxes and a button.
On click of button in codebehind I am saving the value of textbox into databaSE.
Before saving I am just checking whether value is there in db or not.
If it is there I am sending a value to the front end to indicate that record already present.
I want to show a confirm box to the user to choose yes or no
If he is choosing yes the transaction should update the record and if no nothing should happen.
After checking the value present or not How to bring the confirm box in the codebehind?

Regards
Sreedhar Ambati

1 Answer, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 20 Apr 2011, 02:50 PM
Hello Sreedhar,

Just as the standard confirm dialog, radconfirm is created and handled on the client only. More information on how to call JavaScript code from server-side functions is available in various locations on the net. For example you could check this blog post.
If you are using RadControls for ASP.NET AJAX Q1 2011, you could use the RadConfirm() server-side function, that will display a confirmation dialog on the client. Note the dialog is shown when the page is loaded and the dialog is handled on the client.

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        RadWindowManager1.RadConfirm("Are you sure?", "callBackFn", null, null, null, "radconfirm dialog");
    }
</script>
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScript1" runat="server" />
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
    </telerik:RadWindowManager>
    <script type="text/javascript">
        function callBackFn(args)
        {
            //your code here
            alert("returned argument was: " + args);
 
        }
    </script>
    </form>
</body>
</html>

Once you receive the argument from the radconfirm dialog on the client(it is returned in the CallbackFunction), it must be sent to the server after that. This (sending arguments from the client to the server with JavaScript) is a general programming task - for example you can use __doPostBack() or RadAjax's ajaxRequest call to do this.



All the best,
Georgi Tunev
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
General Discussions
Asked by
sreedhar ambati
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Share this question
or