无法使用asp.net调用函数(窗口){}

时间:2015-08-06 08:38:42

标签: javascript c# jquery asp.net

如何从asp.net c#

调用addRect函数

我尝试了这个,但它无法调用该函数,我应该使用什么?

(function (window) {    
    function addRect(x, y, w, h, fill, flag, count) { }
})(window);

Page.ClientScript.RegisterStartupScript(this.GetType(), "addRect", "addRect(x,y,w,h,fill,flag,count);", true);

1 个答案:

答案 0 :(得分:0)

试试这个;

<script type="text/javascript" language="javascript">
    function myfunction(x) {
        alert(x)
    }
</script>

并从你的代码背后;

string myfunction= "myfunction(" + myvalue+ ")";
ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "myfunction", myfunction, true);