更新パネル コントロールがあります。2 つのラジオ ボタンと 2 つの div があります。ラジオボタンをクリックすると、それぞれの div が表示されます。& デフォルトでは、これらのボタンの 1 つがチェックされ、それぞれの div が表示されます。
問題: デフォルトのボタンを選択すると、div は適切に表示されますが、別のボタンを選択すると、ページが 1 分間非アクティブのままになるか、クリックなどのイベントが発生すると、デフォルト ボタンのそれぞれの div が再び表示されます。選択したものの代わりに。
コード:
<asp:UpdatePanel ID="newUP" runat="server">
<ContentTemplate>
<table>
<tr>
<td style="float:left; margin:0px;">
<asp:RadioButton ID="rbtnInclude" runat="server" GroupName="Stores" Checked="true" Text="Include"/><br />
</td>
</tr>
<tr>
<td style="float:left; margin:0px;">
<asp:RadioButton ID="rbtnExclude" runat="server" GroupName="Stores" Text="Exclude"/>
</td>
</tr>
</table>
<table>
<tr>
<td>
<div class="divIn" id="DivIn1" runat="server" style="width:700px; display: block;">
DIV IN TEXT
</div>
</td>
<tr>
<td>
<div class="divEx" id="DivEx1" runat="server" style="width:700px; display: none;"> DIV EX TEXT
</div>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
Javascript:
function enableDisableDiv()
{
if (document.getElementById("<%=rbtnInclude.ClientID %>").checked)
{
$(".divIn").show();
$(".divEx").hide();
}
if (document.getElementById("<%=rbtnExclude.ClientID %>").checked)
{
$(".divIn").hide();
$(".divEx").show();
}
}
コードビハインド:
if (!Page.IsPostBack)
{
rbtnInclude.Attributes.Add("onclick", "javascript: enableDisableDiv();");
rbtnExclude.Attributes.Add("onclick", "javascript: enableDisableDiv();");
}
編集:このパネルは別の更新パネルにもネストされています。