日期:2014-05-19  浏览次数:20788 次

button点第二次才弹出模式窗口
private   void   Button2_Click(object   sender,   System.EventArgs   e)
{
Button1.Text= "111 ";
Button2.Attributes.Add( "onclick ", "window.showModalDialog( 'WebForm2.aspx '); ");  
}

为什么我要点第二次才能打开webform2这个页啊,点第一次Button1.Text= "111 ";这个运行,第二次才运行Button2.Attributes.Add( "onclick ", "window.showModalDialog( 'WebForm2.aspx '); ");  


------解决方案--------------------
Page_Load:

Button1.Text= "111 ";
Button2.Attributes.Add( "onclick ", "window.showModalDialog( 'WebForm2.aspx '); ");

------解决方案--------------------
因为你点了之后才从服务器端设置onclick,第一次没有onclick事件
------解决方案--------------------
在Load时就要设置
Button1.Text= "111 ";
Button2.Attributes.Add( "onclick ", "window.showModalDialog( 'WebForm2.aspx '); ");