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

javascript confirmation and ajax manager

3 Answers 47 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Chase Florell
Top achievements
Rank 1
Chase Florell asked on 07 Sep 2008, 04:33 AM
i cant seem to get my javascript confirmation to fire when using the ajax manager.

ASPX
        <script language="JavaScript" type="text/javascript">  
 
            function confirmSubmit()  
            {  
                var agree=confirm("Are you sure you wish to reset content?");  
                if (agree)  
                    return true ;  
                else  
                    return false ;  
            }  
        </script> 
 
 
 
<asp:Button ID="btnReset" runat="server" Text="Reset" /> 
 
 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnableEmbeddedScripts="true" EnableAJAX="true">  
    <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="btnReset">  
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="RadEditor1" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
    </AjaxSettings> 
    </telerik:RadAjaxManager> 


ASPX.VB
    Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load  
        btnReset.Attributes.Add("onClick=""return confirmSubmit()"""Nothing)  
    End Sub 

Thanks in advance

3 Answers, 1 is accepted

Sort by
0
Chase Florell
Top achievements
Rank 1
answered on 08 Sep 2008, 05:04 AM

i know it's because the ajax manager adds its own "onclick" function, I just dont know how to get around it.

0
Accepted
Konstantin Petkov
Telerik team
answered on 08 Sep 2008, 06:00 AM
Hi Chase,

It seems this documentation article would help you implement that. See how the OnRequestStart event handler is used.

Kind regards,
Konstantin Petkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Chase Florell
Top achievements
Rank 1
answered on 08 Sep 2008, 07:56 PM
Great I got it to work, however the article you sent is incomplete... I had to do some digging.

Basically here is the final code
<script type='text/javascript'>  
    function OnRequestStart(ajaxControl, eventArgs)  
    {  
        var eventTarget = eventArgs.EventTarget;  
        if (eventTarget == "<%= btnReset.ClientID %>")  
        {  
            return confirm('This will reset your page content\nto its original state.  Continue?');  
        }  
        else  
        {  
            return false;  
        }  
    }   
</script> 
 
<asp:Button ID="btnReset" runat="server" Text="Reset" /> 
 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" ClientEvents-OnRequestStart="OnRequestStart">  
    <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="btnReset">  
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="RadEditor1" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
    </AjaxSettings> 
    </telerik:RadAjaxManager> 
 
 

I had to add the "ClientEvents-OnRequestStart="OnRequestStart" in the AJAX manager (which is not in the documentation... or I'm just an idiot... one of the two)
Tags
Ajax
Asked by
Chase Florell
Top achievements
Rank 1
Answers by
Chase Florell
Top achievements
Rank 1
Konstantin Petkov
Telerik team
Share this question
or