Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Issue in calling the method

$
0
0

Hi All

I have created a file "test.js" in asp.net project with the following code

function Alert()
{
    alert("Alert");
}

There is another file where I am doing lazy loading using register script and require methods.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title></title><script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script><script src="http://ajax.microsoft.com/ajax/beta/0911/Start.js"></script></head><body><form id="form1" runat="server"><asp:ScriptManager runat="server" EnableCdn="True"></asp:ScriptManager><a href="#">Click Me</a></form><script type="text/javascript">$(document).ready(
            function () {$("a").click(
                    function () {
                        try {
                            Sys.loader.defineScript({
                                name: "MyLibrary",
                                debugUrl: "%/../test.js",
                                releaseUrl: "%/../test.js",
                                dependencies:
                                  ["jQuery", "Start"],
                                isLoaded: !!(window.jQuery)
                            });

                            Sys.require(Sys.scripts.MyLibrary);
                            Alert();

                        } catch (e) {
                            alert(e);
                        }
                    });
            });
    </script></body></html>

But I am getting the error - "ReferenceError: Alert is not defined". Am I doing anything wrong.


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>