Why the Jquery doesnt work when I move the code into a separate .js file

Last Reply on Mar 11, 2012 11:20 AM By Mudassar

Posted on Mar 11, 2012 11:18 AM

Hello, I have follow this post and the code works well if i put it under the same page in the script section.

http://www.aspsnippets.com/Articles/Create-dynamic-textbox-using-JavaScript-in-ASP.Net.aspx


However, if i move to a separate js file call admin-btn.js and then it gives me error when it comes to this part of code:
 

 function RecreateDynamicTextboxes() {
        var values = eval('<%=Values%>');
        if (values != null) {
            var html = "";
            for (var i = 0; i < values.length; i++) {
                html += "<div>" + GetDynamicTextBox(values[i]) + "</div>";
            }
            document.getElementById("TextBoxContainer").innerHTML = html;
        }
    }

The message is about sytax error in runtime (sorry it was in chinese..)

Microsoft JScript 執行階段錯誤: 語法錯誤

 

i have put all the code inside here in admin-btn.js
$(document).ready(function () {

//All codes

});

 

Can anyone help me on this? THanks!

This question does not have replies that have been liked.