我想在文本框中的文本更改上使用文本框连接 VB.Net 中的文本字段。
目前我正在做下拉选择更改的任务:
VB代码
Protected Sub ddlCitizenSex_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlCitizenSex.SelectedIndexChanged
If ddlCitizenSex.SelectedValue = "Male" Then
txtCitizenName.Text =
txtCitizenFirstName.Text + " " + "S/O" +
txtCitizenFatherName.Text + " " + "S/O" +
txtCitizenGFatherName.Text + " " + txtCitizenFamilyName.Text
Else
txtCitizenName.Text =
txtCitizenFirstName.Text + " " + "D/O" +
txtCitizenFatherName.Text + " " + "S/O" +
txtCitizenGFatherName.Text + " " + txtCitizenFamilyName.Text
End If
End Sub
我写了下面的代码来试试,但没有用:
VB代码
Private Sub ModifyCitizenName()
If ddlCitizenSex.SelectedValue = "Male" Then
txtCitizenName.Text =
txtCitizenFirstName.Text + " " + "S/O" +
txtCitizenFatherName.Text + " " + "S/O" +
txtCitizenGFatherName.Text + " " + txtCitizenFamilyName.Text
Else
txtCitizenName.Text =
txtCitizenFirstName.Text + " " + "D/O" +
txtCitizenFatherName.Text + " " + "S/O" +
txtCitizenGFatherName.Text + " " + txtCitizenFamilyName.Text
End If
End Sub
Protected Sub txtCitizenFirstName_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtCitizenFirstName.TextChanged
ModifyCitizenName()
End Sub
Protected Sub txtCitizenFamilyName_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtCitizenFamilyName.TextChanged
ModifyCitizenName()
End Sub
ASP 代码
<asp:Label ID="lblCitizenFamilyName" runat="server" Text="">Family Name</asp:Label>
<asp:TextBox ID="txtCitizenFamilyName" AutoPostBack="true" runat="server"></asp:TextBox>
<asp:Label ID="lblCitizenFirstName" runat="server" Text="">First Name</asp:Label>
<asp:TextBox ID="txtCitizenFirstName" AutoPostBack="true" runat="server"></asp:TextBox>
<asp:Label ID="lblCitizenSex" runat="server" Text="">Sex</asp:Label>
<asp:DropDownList ID="ddlCitizenSex" runat="server"></asp:DropDownList>
如您所见,我在两个文本框中都使用了AutoPostBack 。
我是否必须使用<Triggers>
文本框。
以及如何执行任务。希望大家帮忙。谢谢