Login.LoginButtonType Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur jenis tombol yang akan digunakan saat merender tombol Login .
public:
virtual property System::Web::UI::WebControls::ButtonType LoginButtonType { System::Web::UI::WebControls::ButtonType get(); void set(System::Web::UI::WebControls::ButtonType value); };
public virtual System.Web.UI.WebControls.ButtonType LoginButtonType { get; set; }
member this.LoginButtonType : System.Web.UI.WebControls.ButtonType with get, set
Public Overridable Property LoginButtonType As ButtonType
Nilai Properti
Salah ButtonType satu nilai enumerasi. Default adalah Button.
Pengecualian
Properti LoginButtonType tidak diatur ke nilai enumerasi yang valid ButtonType .
Contoh
Contoh kode berikut menunjukkan berbagai jenis tombol masuk yang tersedia untuk Login kontrol.
Penting
Contoh ini berisi kotak teks yang menerima input pengguna, yang merupakan potensi ancaman keamanan. Secara default, ASP.NET halaman Web memvalidasi bahwa input pengguna tidak menyertakan elemen skrip atau HTML. Untuk informasi selengkapnya, lihat Gambaran Umum Eksploitasi Skrip.
<%@ Page Language="C#" AutoEventWireup="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void changeButton_Click(Object sender, EventArgs e)
{
if (ChooseButtonType.SelectedValue == "Button")
{
Login1.LoginButtonType = ButtonType.Button;
}
if (ChooseButtonType.SelectedValue == "Image")
{
Login1.LoginButtonType = ButtonType.Image;
}
if (ChooseButtonType.SelectedValue == "Link")
{
Login1.LoginButtonType = ButtonType.Link;
}
Login1.LoginButtonText = Server.HtmlEncode(buttonText.Text);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<table>
<tr>
<td>Login Button Text:
</td>
<td>
<asp:TextBox id="buttonText"
runat="server"
Text="Login"></asp:TextBox>
</td>
<td>Button Type:
</td>
<td>
<asp:DropDownList id="ChooseButtonType"
runat="server">
<asp:ListItem value="Button"
selected="true"></asp:ListItem>
<asp:ListItem value="Image"></asp:ListItem>
<asp:ListItem value="Link"></asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:Button id="changeButton" runat="server" Text="Change" OnClick="changeButton_Click"></asp:Button>
</td>
</tr>
<tr>
<td colspan="4"
align="center">
<asp:Login id="Login1"
runat="server"
LoginButtonType="Image"
LoginButtonText="Log in to Web Site."
LoginButtonImageUrl="images\login.png">
</asp:Login>
</td>
</tr>
</table>
</form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub changeButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If (ChooseButtonType.SelectedValue = "Button") Then
Login1.LoginButtonType = System.Web.UI.WebControls.ButtonType.Button
End If
If (ChooseButtonType.SelectedValue = "Image") Then
Login1.LoginButtonType = System.Web.UI.WebControls.ButtonType.Image
End If
If (ChooseButtonType.SelectedValue = "Link") Then
Login1.LoginButtonType = System.Web.UI.WebControls.ButtonType.Link
End If
Login1.LoginButtonText = Server.HtmlEncode(buttonText.Text)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="Form1" runat="server">
<table>
<tr>
<td>Login Button Text:
</td>
<td>
<asp:TextBox id="buttonText"
runat="server"
Text="Login"></asp:TextBox>
</td>
<td>Button Type:
</td>
<td>
<asp:DropDownList id="ChooseButtonType"
runat="server">
<asp:ListItem value="Button"
selected="true"></asp:ListItem>
<asp:ListItem value="Image"></asp:ListItem>
<asp:ListItem value="Link"></asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:Button id="changeButton" runat="server" Text="Change" OnClick="changeButton_Click"></asp:Button>
</td>
</tr>
<tr>
<td colspan="4"
align="center">
<asp:Login id="Login1"
runat="server"
LoginButtonType="Image"
LoginButtonText="Log in to Web Site."
LoginButtonImageUrl="images\login.png">
</asp:Login>
</td>
</tr>
</table>
</form>
</body>
</html>
Keterangan
Properti LoginButtonType menentukan jenis tombol yang akan digunakan untuk tombol Login masuk kontrol. Tabel berikut ini menjelaskan berbagai jenis tombol.
LoginButtonType Pengaturan | Jenis tombol yang dirender |
---|---|
Button | Tombol HTML dengan teks yang ditentukan dalam LoginButtonText properti . |
Image | Sebuah gambar. URL gambar ditentukan dalam LoginButtonImageUrl properti . String yang ditentukan dalam LoginButtonText properti digunakan sebagai teks alternatif untuk gambar. |
Link | Tautan HTML dengan teks yang ditentukan dalam LoginButtonText properti . |
LoginButtonType Ketika properti diatur ke Button atau Link, konten LoginButtonImageUrl properti diabaikan.
Berlaku untuk
Lihat juga
Saran dan Komentar
https://aka.ms/ContentUserFeedback.
Segera hadir: Sepanjang tahun 2024 kami akan menghentikan penggunaan GitHub Issues sebagai mekanisme umpan balik untuk konten dan menggantinya dengan sistem umpan balik baru. Untuk mengetahui informasi selengkapnya, lihat:Kirim dan lihat umpan balik untuk