简体   繁体   中英

Failed to trigger javascript from backend

I just switch from coding in vb to c#, so I've got a lot of things to catch up and please assist me on this 1.

I have a javascript function on aspx page, and I would like trigger the function from backend.

Below is my code at backend.

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

Unfortunately I got an error as below.

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

Please help.

尝试从PageLoad方法执行此操作

用这个

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM