【发布时间】:2017-09-27 00:58:21
【问题描述】:
我有一个大问题,我正在尝试从 c# 打开一个模式,但是我已经阅读了所有堆栈溢出的答案和问题,但任何一个都帮助了我。 这就是问题所在。
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
getProduct();
//ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
ScriptManager.RegisterStartupScript(this, this.GetType(), "mdlError", "$('#mdlError').modal();", true);
}
}
这在我在 .net 中使用母版页时有效,但是当我运行应用程序时,什么都没有发生,代码只是运行但它不会崩溃。我调试了这段代码,好像有问题:
RegisterStartupScript error CS0428: Cannot convert method group 'RegisterStartupScript' to non-delegate type 'object'. Did you intend to invoke the method?
有人可以帮帮我吗? 我正在使用 Asp.NET 和 C#。 提前致谢。
【问题讨论】:
-
首先,从服务器端调用脚本并不是一个好习惯。为什么不创建外部js文件并调用modal?还是在页面本身?
-
如果执行某些方法有任何错误,如何调用模态?
-
那是因为你试图通过 RegisterStartupScript 调用 modal。我的建议是创建一个调用modal的外部js文件?
-
你能提供一些例子吗?
标签: c# jquery asp.net twitter-bootstrap