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

How to conditionally stop Ajax based on toolbar button clicked

2 Answers 85 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Randy
Top achievements
Rank 1
Randy asked on 25 Feb 2009, 08:32 PM
i have a RadToolbar and RadGrid inside of an Ajax Panel. One of the buttons performs the Export to Excel and I following the instructions for disabling the Ajax use when this buttons pressed because we need to do a full postback.  This all works fine but it makes all of the button clicks do full postbacks.  I have other buttons such as Refresh that I want to use  Ajax.  Here is my javascript routine...

<

 

telerik:RadScriptBlock runat=server>

 

<

 

 

script type="text/javascript">

 

 

 

function pnlRequestStarted(ajaxPanel, eventArgs) {

 

 

 

if (eventArgs.EventTarget == "<%=ToolbarUniqueID %>") {

 

eventArgs.EnableAjax = false

;

 

 

 

}

}

 

 

</

 

script>

 

</

 

 

telerik:RadScriptBlock>

I'm passing the  unique id of the Radtoolbar.  Can I somehow get to the actual button value clicked inside of this routine?

 

Basically I'm lookign for logic that will allow me to do the following.

if button.value = ExporttoExcel
  eventArgs.EnableAjax = false
else
 eventArgs.EnableAjax = true

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 Feb 2009, 10:48 AM
Hi Randy,

Try the following client side code and see whether it is working. I tried to get the eventArgument() and checked the string passed for getting the corresponding button clicked in RadToolBar.

JavaScript:
<script type="text/javascript">  
function pnlRequestSvtarted(ajaxpanel, eventArgs)   
{  
    if (eventArgs.EventTarget == "<%=RadToolBar1.UniqueID %>")  
    {   
        if (eventArgs.get_eventArgument() == 0) //0 if first button -set it accordingly 
        {  
            eventArgs.set_enableAjax(false);  
        }  
        else  
        {  
            eventArgs.set_enableAjax(true);  
        }  
    }      
}  
</script>  

Thanks,
Shinu.
0
Randy
Top achievements
Rank 1
answered on 26 Feb 2009, 11:48 AM
Thanks that worked. 
Tags
Ajax
Asked by
Randy
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Randy
Top achievements
Rank 1
Share this question
or