Reputation: 13437
please consider this code:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table border="1" cellpadding="8" cellspacing="0" width="700px" style="background-color: Aqua">
<tr>
<td style="direction: rtl">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
<td style="direction: ltr">
F1
</td>
</tr>
<tr>
<td style="direction: rtl">
<asp:DropDownList ID="Drp_1" runat="server" ClientIDMode="Static">
<asp:ListItem Value="1">Head of household</asp:ListItem>
<asp:ListItem Value="2">Spouse</asp:ListItem>
<asp:ListItem Value="3">Child</asp:ListItem>
</asp:DropDownList>
</td>
<td>
F2
</td>
</tr>
<tr>
<td style="direction: rtl">
<asp:RadioButtonList ID="Rad_7" runat="server" ClientIDMode="Static">
<asp:ListItem Text="1" Value="1"></asp:ListItem>
<asp:ListItem Text="2" Value="2"></asp:ListItem>
<asp:ListItem Text="3" Value="3"></asp:ListItem>
<asp:ListItem Text="4" Value="4"></asp:ListItem>
</asp:RadioButtonList>
</td>
<td>
F3
</td>
</tr>
<tr>
<td>
<asp:Button ID="BindAgain" runat="server" Height="44px" Text="Submit" ClientIDMode="Static"
Width="207px" OnClick="BindAgain_Click" />
</td>
<td>
<asp:Button ID="btn" runat="server" Height="44px" Text="Submit" ClientIDMode="Static"
Width="207px" OnClick="btn_Click" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
<asp:TextBox ID="isPostback" ClientIDMode="Static" runat="server"></asp:TextBox>
<h1 style="color: Green; font-size: large; font-weight: bold; display: none;" id="nima">
Progress ...
</h1>
and this is code bihind:
protected void btn_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(4000);
TextBox1.Text = "nima";
}
protected void BindAgain_Click(object sender, EventArgs e)
{
Drp_1.SelectedIndex = 1;
Rad_7.SelectedIndex = 3;
isPostback.Text = "1";
}
when I want to check value of isPostback
after postback using jQuery I get ""
.this is my javascript code:
function pageLoad() {
$('#nima').hide();
$(document).ready(function () {
//alert("NIMA");
$("#Drp_1").on("change", function () {
if ($(this).val() == 2) {
if ($('#Rad_7 input:checked').val() != null && $('#Rad_7 input:checked').val() > 1 && $('#Rad_7 input:checked').val() != 2) {
if ($('#isPostback').val() == "0") {//<<<<<<<<
alert('Wrong option');
}
}
}
else {
$('#Rad_7 input').removeAttr("checked");
}
}).change();
$("#Rad_7 input").on("change", function () {
if ($(this).val() == 2) {
if ($('#Drp_1').val() != null && $('#Drp_1').val() > 1 && $('#Drp_1').val() != 2) {
if ($('#isPostback').val() == "0") {//<<<<<<<<
alert('Wrong option');
}
}
}
if ($("#Drp_1").val() != null && $("#Drp_1").val() == 2) {
if ($('#Rad_7 input:checked').val() != null && $('#Rad_7 input:checked').val() != 'undefiend' && $('#Rad_7 input:checked').val() != 2) {
if ($('#isPostback').val() == "0") {//<<<<<<<<
alert('Wrong option');
}
}
}
}).change();
});
}
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);
function InitializeRequest(sender, args) {
$('#nima').css('display', 'block');
}
function EndRequest(sender, args) {
$('#nima').css('display', 'none');
}
where is my mistake?
thanks
Upvotes: 0
Views: 837
Reputation: 691
Your textbox is outside of the UpdatePanel. It is not receiving the update when the postback is triggered from within the panel.
Upvotes: 1