未能从后端触发javascript

Failed to trigger javascript from backend

本文关键字:javascript 后端      更新时间:2023-09-26

我刚从vb中的编码切换到c#,所以我有很多事情要做,请在这方面帮助我1。

我在aspx页面上有一个javascript函数,我想从后端触发该函数。

下面是我在后台的代码。

ScriptManager.RegisterStartupScript(this, this.GetType(), "closeScript", "showMessage('test')", true);

不幸的是,我出现了如下错误。

Error   30  Keyword 'this' is not valid in a static property, static method, or static field initializer.

请帮忙。

尝试从PageLoad方法执行此操作

使用此

    ClientScript.RegisterClientScriptBlock(this.GetType(), "closeScript", "showMessage('test')", true);