jeudi 12 février 2015

ASP.Net submit button click event not working after dropdown list index change in JavaScript


I have an asp.net application. I am displaying a confirmation popup alert when the selected index changes to a specific value ("Cancelled") in dropdown list.



<asp:DropDownList ID="ddlStatus" runat="server" CssClass="selectstyle" DataTextField="Name" DataValueField="ID" onchange="GetSelectedItem(this)" />


The dropdown has 4 values - "Pending", "Fixed", "Responded" and "Cancelled"


So when user selects "Cancelled" value, I am displaying a confirmation popup box. Depending on the user selection from the confirmation box, I am modifying the UI of the page and update the changes (submit button works).



function GetSelectedItem(x) {
if (x.value == 4) {
if (confirm("Are you sure you want to cancel support ticket ?") == true) {
document.getElementById("lbl_CancellationReason").style.display = 'block';
document.getElementById("tbx_CancellationReason").style.display = 'block';
}
}
else {
document.getElementById("lbl_CancellationReason").style.display = 'none';
document.getElementById("tbx_CancellationReason").style.display = 'none';
//document.getElementById('<%= btnSubmit.ClientID %>').click();
$('btnSubmit').trigger('click');
}
}


But when user selects any other value from the dropdown list ("Pending", "Fixed", "Responded") or makes any other changes in the page, my submit button (update) is not working. It does not give any error but nothing happens on my page.


Here is my cancellation reason and update button,



<td class="label" align="right">
<div id="lbl_CancellationReason" runat="server" style="display:none">
Cancellation Reason :
</div>
</td>
<td>
<div id="tbx_CancellationReason" runat="server" style="display:none">
<asp:TextBox ID="tbxCancellationReason" runat="server" CssClass="selectstyle" TextMode="MultiLine" Width="400" Height="50"> </asp:TextBox>
<asp:RequiredFieldValidator ErrorMessage="Please enter cancellation reason." ValidationGroup="CancellationReason" ControlToValidate="tbxCancellationReason" runat="server" />
</div>
</td>

<asp:Button ID="btnSubmit" runat="server" Text="Update Details" Style="display: inline; margin-left: 15px;" OnClick="btnUpdate_Click" CssClass="selectstyle" UseSubmitBehavior="false" ValidationGroup="CancellationReason"/>


Not sure what to do.





Aucun commentaire:

Enregistrer un commentaire