我有几个在加载页面时隐藏的表单元素。用户可以在选择单选按钮时取消隐藏表单元素。表单有两列。一个用户,一个用户配偶。最初加载页面时,默认为隐藏配偶框。
ASP
<asp:ScriptManager runat="server" ID="scmMgr1" LoadScriptsBeforeUI="true"
AjaxFrameworkMode="Enabled"
CompositeScript-ScriptMode="Release"
EnableCdn="true"
EnableCdnFallback="true"
EnableScriptLocalization="true"></asp:ScriptManager>
<asp:TextBox runat="server" ID="txtCurrentAgeUser" OnTextChanged="txtCurrentAgeUser_OnTextChanged" AutoPostBack="true" Columns="2" />
<asp:TextBox runat="server" ID="txtCurrentAgeSpouse" OnTextChanged="txtCurrentAgeSpouse_OnTextChanged" AutoPostBack="true" Columns="2" />
代码隐藏
protected void HideSpouseFields () {
txtCurrentAgeSpouse.Visible = false;
}
protected void ShowSpouseFields () {
txtCurrentAgeSpouse.Visible = false;
}
protected void txtCurrentAgeUser_OnTextChanged (object sender, EventArgs e) {
if (txtRetirementAgeUser.Text.Trim ().Length > 0) {
txtLifeExpectancyUser.Text = LifeExpectancy (Convert.ToInt16 (txtRetirementAgeUser.Text.Trim ()), rdoGenderUser.SelectedValue).ToString ();
}
}
protected void txtCurrentAgeSpouse_OnTextChanged(object sender, EventArgs e) {
if (txtRetirementAgeSpouse.Text.Trim ().Length > 0) {
txtLifeExpectancySpouse.Text = LifeExpectancy (Convert.ToInt16 (txtRetirementAgeSpouse.Text.Trim ()), rdoGenderSpouse.SelectedValue).ToString ();
}
}
答案 0 :(得分:0)
您正在使用UpdatePanel?尝试用它来测试。