我有一个 Enable.js
文件,其中包含 Enable()
函数。我想从 C# 代码隐藏中调用此 Enable
函数。我的 .js
文件和 c# 文件位于同一个应用程序中。
我已经尝试过这个,但它对我没有帮助。
Page.ClientScript.RegisterStartupScript(this.GetType(), "click", "Enable(true)", true);
最佳答案
试试这个:
ScriptManager.RegisterClientScriptInclude(
this,
typeof(Page),
"Enable-js",
ResolveClientUrl("~/scripts/Enable.js"));
ScriptManager.RegisterStartupScript(
this, GetType(), Guid.NewGuid().ToString(),
"Enable(True);", true);
关于c# - 如何从 C# 代码调用 javascript?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15021117/