简体   繁体   English

立即在C#的服务器端调用Javascript函数

[英]Invoke Javascript function immediately on Server Side in C#

I am using the below code to call a JavaScript function on the server side, but the JavaScript function is not called immediately and is only executed only after all codes on the Server side is finished executing. 我正在使用以下代码在服务器端调用JavaScript函数,但是JavaScript函数不会立即调用,仅在服务器端的所有代码完成执行后才执行。 Is there any way invoke the JavaScript function call immediately. 有什么办法可以立即调用JavaScript函数。

protected string Pass_value()
{
    ScriptManager.RegisterClientScriptBlock(this, typeof(string), "answer",getanswer(), true);

    answer = hdnfldVariable.Value.ToString();
    return answer;
}

与其在后端代码中调用javascript方法,不如尝试使用ajax调用您的后端方法,然后在javascript代码中使用返回值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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