后台用ScriptManager.RegisterClientScriptBlock,调前台JS,找不到控件ID怎么办啊?有没有好的解决办法?

解决方案 »

  1.   

    具体code 贴了来看看撒 
      

  2.   

    代码大概下面这样,主要是因为。代码执行顺序问题,JS打印出来后,要调用的那个BUTTON还没打印出来,所以找不到,有没有什么好的解决办法,我就这点分了,谢谢。  ScriptManager.RegisterClientScriptBlock(UpdatePanel1, UpdatePanel1.GetType(), _
                                                            "", "WinCloseWebBtn2();", True)
        <script type="text/javascript" language="javascript">
            function WinCloseWebBtn2() {
                var date = new Date();
                var parameter = date.getFullYear() + "_" + date.getMonth() + "_" + date.getDay() + "_" + date.getHours() + "_" + date.getMinutes() + "_" + date.getSeconds() + "_" + date.getMilliseconds();
                var str = "PasswordChangeDialog.aspx";
                str = str + "?AAA=" + parameter;
                window.returnValue = window.showModalDialog(str, null, 'dialogWidth=918px; dialogHeight=600px;center:1;scroll:0; help:0; status:0 ');
                if (window.returnValue == 1) {                var obj = document.getElementById("<%=WebImageButton2.ClientID%>");
                    obj.click();
                }
            }
        </script>
        <title meta:resourcekey="TitleResource1"></title>
    </head>
    <body>
    ...
    <body/>
      

  3.   

    RegisterClientScriptBlock
    换成RegisterStartupScript 
      

  4.   

    我一般是用参数把ClientID传进去的。
    这样拼字符串的时候容易拼一些。只要直接拼一个调用的函数就可以了。参数是ClientID。
      

  5.   

    RegisterStartupScript和RegisterClientScriptBlock有什么区别?谢谢