I always thought the result should be the opposite, since Request.Write outputs the string to the top of page and RegisterStartupScript outputs the string before </form>do you have any javascript code that depends on anything from SmartMenuToc.js?

解决方案 »

  1.   

    没有,我的 .aspx 文件没有任何其他 javascript 代码,.aspx.vb 文件中也只有这么一段代码,唉,真是不知道时什么原因。
      

  2.   

    如果页面没有<form runat=server>那么RegisterXXXScript都不起作用.
    设计控件的时候就要考虑控件是Render型的还是PostBack型的。
    例如你的控件只是为了输出html+js,那么最好在Render里做手脚.
      

  3.   

    To LevinForum(forum.lostinet.com):
        我的页面里面有<form runat=server>,使用RegisterStartupScript 发出的 javascript 代码也能执行,只是执行错误;而使用 Response.Write 产生的代码执行却没有错误。
        我的 .aspx 中没有控件
      

  4.   

    发现了一点问题:在我的类文件“SmartMenuToc.js”中会产生一些控件,如果使用 RegisterStartupScript 发出代码,那么这些控件会在 <form ></form> 中,所以访问时会要包含 form 的名称;而使用 Response.Write ,这些产生的代码会在 <form ></form>外,这样在 SmartMenuToc.js 访问控件的方式就不用改变,执行也就不会出错。
        我想可能是这个问题。