我对 ASP.NET ImageButton 控件有疑问。
我想要的是:当我点击图片时,我将被重定向到 Google、Facebook 或 Twitter 的登录页面,但这不会发生。这是我的登录页面代码:
<section id="socialLoginForm">
<h2>Use another service to log in.</h2>
<uc:OpenAuthProviders runat="server" ID="OpenAuthLogin" />
<asp:ListView runat="server" ID="providerDetails" ItemType="Microsoft.AspNet.Membership.OpenAuth.ProviderDetails"
SelectMethod="GetProviderNames" ViewStateMode="Disabled">
<ItemTemplate>
<asp:ImageButton ID="Login" runat="server" Width="40" Height="40" ImageUrl='<%# Item.ExtraData["Icon"] %>' AlternateText="Log in using your <%#: Item.ProviderDisplayName %> account." />
</ItemTemplate>
<EmptyDataTemplate>
<p>There are no external authentication services configured. </p>
</EmptyDataTemplate>
</asp:ListView>
</section>
这是后面的代码:
public partial class Login : Page
{
protected void Page_Load(object sender, EventArgs e)
{
RegisterHyperLink.NavigateUrl = "Register.aspx";
OpenAuthLogin.ReturnUrl = Request.QueryString["ReturnUrl"];
var returnUrl = HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]);
if (!String.IsNullOrEmpty(returnUrl))
{
RegisterHyperLink.NavigateUrl += "?ReturnUrl=" + returnUrl;
}
}
public string ReturnUrl { get; set; }
public IEnumerable<ProviderDetails> GetProviderNames()
{
return OpenAuth.AuthenticationClients.GetAll();
}