I am having trouble calling an external javascript function from my asp.net page
I have a file called user.js which I have this..
UseThisNewThing:function () {
alert("In Function External");
}
My asp.net page references this file in the head tag..
<script src="Js/User.js" type="text/javascript"></script>
Now I wanna call this function via jquery so in the code behind I have this
if (page != null && !string.IsNullOrWhiteSpace(scriptName) && !string.IsNullOrWhiteSpace(scriptCommands))
{
Type parentType = page.GetType();
// Check to see if the include script exists already.
if (!page.ClientScript.IsStartupScriptRegistered(parentType, scriptName))
{
page.ClientScript.RegisterStartupScript(parentType, scriptName,
"<script type=\"text/javascript\">\njQuery(document).ready(function () {" + scriptCommands + "});</script>"); ;
}
}
where parentType is this.Page, scriptName="InitPage", and
scriptCommands=@"User.UseThisNewThing();"
I must be miossing something in this hook up beacuse I cannot get the alert to fire on page load
if the user is name of class than you scriptcommand will be
you cannot call the function direcly without creating instance of class