日期:2014-05-18  浏览次数:20375 次

请解释如下代码为什么不能通过,onclick和onserverclick
我希望,首次加载时出现first   load,点击按钮后出现clientclick,second   load,serverclick

<script   language=javascript>
                function   aaa()
                {
               
                    alert( "clientclick ");
  return   true;
                 
                }
  </script>
  <script   language=cs   runat=server>
       
void   Page_Load(Object   Sender,EventArgs   e)
{
if(!IsPostBack)
Response.Write( "first   load ");
else
Response.Write( "second   load ");
}

void   bbb(Object   Sender,EventArgs   e)
{

Response.Write( "serverclick ");

}
       
        </script>

<body   >
        <form   id= "form1 "   runat=server>
<input   type=button   id=btn1   onclick= "aaa() "   onserverclick= "bbb() "   runat=server   NAME= "btn1 "/>
        </form>
</body>

------解决方案--------------------
不能降紫写,如果即要执行JS,又要执行CS,则需要在PAGE_LOAD中加入
btn1.Attributes.Add( "onclick ", "aaa() ");
------解决方案--------------------
JF
------解决方案--------------------
jf
------解决方案--------------------
<input type= "button " id= "btn1 " onclick= "aaa(); " onserverclick= "bbb " runat= "server "/>