2013-02-20 12 views
0

代碼:AcceptButton指令?

form1.AcceptButton = accessButton; 

,我把:

using System.Windows.Forms; 

但它不找到它。它說System.Web.UI.HtmlControl.HtmlForm沒有這個定義。嗯?

+1

System.Windows.Forms和System.Web.UI.HtmlControl.HtmlForm是兩個非常不同的東西。 Windows Forms用於創建桌面應用程序,System.Web.UI用於創建ASP.NET解決方案。您想做什麼? – 2013-02-20 14:59:00

+0

網站方面:) ASP.NET,我在一個MasterPage ... – markzzz 2013-02-20 15:00:40

回答

1

把控制在面板和設置DefaultButton

<asp:Panel DefaultButton="accessButton" runat="server">  
    <asp:TextBox id="myname" runat="server" /> 
    <asp:Button id="accessButton" Text="Submit" runat="server" /> 
</asp:Panel> 
1

System.Windows.Forms和System.Web.UI是兩個完全不同的系統。 Windows窗體用於創建桌面應用程序,System.Web.UI用於創建ASP.NET頁面。您不能在ASP.NET中使用WinForms。

請參閱ASP.NET上的here

1

使用Page.Form.DefaultButton來代替。