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

RadAjaxManager not loading JavaScript Function

2 Answers 172 Views
ScriptManager and StyleSheetManager
This is a migrated thread and some comments may be shown as answers.
Felix
Top achievements
Rank 1
Felix asked on 03 Feb 2015, 02:05 PM
I'm having a weird occurrence when adding a RadAjaxManager to a Webform. From ButtonClick codebehind I am calling a java script function successfully, but fails when I add a RadAjaxManager.

CodeBehind:
    protected void btnUpload3DModel_Click(object sender, EventArgs e)
        {

            try
            {
                FileUpload fileUpload = FileUploadControl;

                string physicalFolder = Server.MapPath("~/assets/");
                if (fileUpload.HasFile)
                {
                    string uploadFile = physicalFolder + fileUpload.FileName;
                    fileUpload.SaveAs(uploadFile);

                    string testFile = "/assets/" + fileUpload.FileName;
   
                   ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "NovaCopyStlViewer('" + testFile + "')", true);
                }
            }
            catch (Exception)
            {

                throw;
            }

        }

Javascript function:

 <script type="text/javascript">
        function NovaCopyStlViewer(file)
        {

            var cv = document.getElementById('canvas_drop');
            cv.style.display = 'block';

            var e = document.getElementById('select_options');
            e.style.display = 'block';



            var mycanvas = document.getElementById('upload_canvas');
            var viewer = new JSC3D.Viewer(mycanvas);
            var theScene = new JSC3D.Scene;

            var stlpath = file;
            viewer.setParameter('SceneUrl', stlpath);
            viewer.setParameter('InitRotationX', 20);
            viewer.setParameter('InitRotationY', 20);
            viewer.setParameter('InitRotationZ', 0);
            viewer.init();
            viewer.update();
        }
    </script>



The error I am seeing after adding RadAjaxManager is as follows
JavaScript critical error at line 343, column 42 in http://localhost:32135/3DPrototypeQuote.aspx\n\nSCRIPT1004: Expected ';' 

Notice there is no SemiColon between NovaCopyStlViewer('/assets/Inverted.stl') and Sys.Application.add_init(function() 
This is where Visual Studio is showing the error. 

DOM:
<script type="text/javascript">
//<![CDATA[
NovaCopyStlViewer('/assets/Inverted.stl')Sys.Application.add_init(function() {
    $create(Telerik.Web.UI.RadAjaxManager, {"_updatePanels":"","ajaxSettings":[],"clientEvents":{OnRequestStart:"",OnResponseEnd:""},"defaultLoadingPanelID":"","enableAJAX":true,"enableHistory":false,"links":[],"styles":[],"uniqueID":"ctl00$ContentPlaceHolder1$RadAjaxManager1","updatePanelsRenderMode":0}, null, null, $get("ctl00_ContentPlaceHolder1_RadAjaxManager1"));
});
//]]>
</script>





















2 Answers, 1 is accepted

Sort by
0
Felix
Top achievements
Rank 1
answered on 04 Feb 2015, 11:54 AM
I was hoping to get a solution to this from the Telerik  team. Has anyone encountered a similar occurrence? 
0
Peter Filipov
Telerik team
answered on 06 Feb 2015, 11:11 AM
Hello Felix,

Please review the attached project it shows how this could be implemented. In your project you should add semicolon at the end of the function's definition.
ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text","NovaCopyStlViewer('" + testFile + "');"true);


Regards,
Peter Filipov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
ScriptManager and StyleSheetManager
Asked by
Felix
Top achievements
Rank 1
Answers by
Felix
Top achievements
Rank 1
Peter Filipov
Telerik team
Share this question
or