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

[Solved] Adding OnRequestStartEvent from Codebehind

3 Answers 196 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Markus
Top achievements
Rank 2
Markus asked on 18 Jun 2008, 05:55 AM
Hello!

I have build a control that works as fileuploader. Inside the control I want to ensure that the control is not updated with a radajaxmanager that is placed on the page where the control is inlcuded.

I made a recursive FindControl method to find the RadAjaxManager from the Control hierarchy, now I want to add this conditional Postback eventhandler to the radajaxmanager:

 RadAjaxManager mgr = (RadAjaxManager) this.FindControl(this, typeof(RadAjaxManager));
            if (mgr != null)
            {
                mgr.ClientEvents.OnRequestStart =
                    "function conditionalPostback(sender, args) { "
                            +"if(args.EventTarget == \"<%= btnAddFile.UniqueID %>\")"
                           +"{"
                    +"           args.EnableAjax = false;"
                           +"}"
                       +"}";
            }


This doesn' work, I always encounter the javascript error: " '}' needed" when I load the page.

Is there an other possibility to avoid an ajax request by a control? I really need this feature!

Thx in advance & kind regards

3 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 20 Jun 2008, 11:11 AM
Hello Markus,

Can you please try assigning simply the name of the client side handler, and include a separate function, within script tags, as shown here, to temporarily disable the ajax functionality. This should remove the Js error.
I hope this helps.

Sincerely yours,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Markus
Top achievements
Rank 2
answered on 25 Jun 2008, 02:04 PM
ok, i added this piece of code into my control:

<script type="text/javascript"
 function mngRequestStarted(ajaxManager, eventArgs) 
 { 
   var re = new RegExp("\.UpdateButton$|\.PerformInsertButton$", "ig"); 
   if (eventArgs.EventTarget.match(re)) 
    { 
       eventArgs.EnableAjax = false
    } 
 } 
</script> 

and in the codebehind class i have the following code:

 RadAjaxManager mgr = (RadAjaxManager) this.FindControl(thistypeof(RadAjaxManager)); 
            if (mgr != null
            { 
                mgr.ClientEvents.OnRequestStart = "mngRequestStarted"
            } 

now i get the JScript RuntimeError: mngRequestStarted Scriptblock not defined
0
Yavor
Telerik team
answered on 30 Jun 2008, 10:49 AM
Hi Markus,

At this point, in order to progress in the resolution of the issue, I would suggest that you open a formal support ticket, and send us the problematic code, in the form of a small working project. I will review it locally, and get back to you with my findings.

All the best,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Ajax
Asked by
Markus
Top achievements
Rank 2
Answers by
Yavor
Telerik team
Markus
Top achievements
Rank 2
Share this question
or