我創建了一個簡單的.NET用戶控件,用於登錄網站上的會員區(該網站由Umbraco提供支持並使用其會員提供商)。.NET imagebutton - 它需要隱藏代碼嗎?
它工作正常,直到我將登錄用戶控件上的提交按鈕更改爲imagebutton。現在它似乎沒有提交任何內容 - 它只是在點擊時重新加載頁面,並且不會登錄用戶。
此刻,控件只是作爲標準.aspx用戶控件插入,而未被編譯到一個DLL中 - 它與標準提交按鈕一起工作,但不與imagebutton一起使用。我在想,要得到一個imagebutton的工作需要一個代碼隱藏頁面,因此我需要編譯它。這是正確的嗎?
我是一個.NET的總noob,因爲你可以告訴,所以任何建議都會很好。
下面的代碼我現在有:
<%@ Control Language="C#" AutoEventWireup="true" %>
<asp:Login ID="Login1" runat="server">
<LayoutTemplate>
<fieldset>
<legend>Log in details</legend>
<div>
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server"
ControlToValidate="UserName" ErrorMessage="User Name is required."
ToolTip="User Name is required." ValidationGroup="ctl00$Login1">*</asp:RequiredFieldValidator>
</div>
<div>
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
<asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server"
ControlToValidate="Password" ErrorMessage="Password is required."
ToolTip="Password is required." ValidationGroup="ctl00$Login1">*</asp:RequiredFieldValidator>
</div>
<div>
<asp:CheckBox ID="RememberMe" runat="server" Text="Remember me next time." />
</div>
<div>
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
</div>
</fieldset>
<asp:ImageButton ID="LoginButton" runat="server" src="~/css/img/btn_log-in.png" CssClass="rollover" ValidationGroup="ctl00$Login1" />
<br />
<br />
<div style="background: #fc0">STATUS (to be removed) <asp:LoginStatus ID="LoginStatus1" LoginText="Log in or register" LogoutText="Log out" runat="server" /></div>
</LayoutTemplate>
</asp:Login>
在版本唯一不同的這工作是,<asp:ImageButton
的INSEAD ......它有這樣的:
<asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="ctl00$Login1" />
你可以發佈你的「之前」和「之後」的代碼。這將有助於診斷問題。 – ChrisF 2010-07-29 14:22:35