asp.net ページから外部の JavaScript 関数を呼び出すのに問題があります
私はこれを持っているuser.jsというファイルを持っています..
UseThisNewThing:function () {
alert("In Function External");
}
私のasp.netページは、ヘッドタグでこのファイルを参照しています..
<script src="Js/User.js" type="text/javascript"></script>
今、私はjqueryを介してこの関数を呼び出したいので、コードビハインドでこれを持っています
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>"); ;
}
}
ここで、parentType は this.Page でscriptName="InitPage",
あり、
scriptCommands=@"User.UseThisNewThing();"
ページの読み込み時にアラートを発することができないため、このフックアップで何かを誤解しているに違いありません