benjamin200
New Member
In my Asp project, I have a radio button inside my gridview. The radio button only allows user to select once every time. However when user clicks a radio button, a confirm message will appear and the record will only be saved if the user clicks "OK". Everything is working, but now I'm facing a problem. The radio button \[code\]oncheckedchanged\[/code\] seems to not fire when user clicks "OK". How can I fire the radio button event once the user clicks "Ok"?Here is my code:Javascript\[code\]function RadioCheck(rb) { var gv = document.getElementById('Content_PageContent_ucSubMenuItem_module_sales_customer_submenuitem_contactpersonlist_ascx_gvContactPersonList');var rbs = gv.getElementsByTagName("input"); for (var i = 0; i < rbs.length; i++) { if (rbs.type == "radio") { //if radio button is check but not the selected value then false if (rbs.checked && rbs != rb) { rbs.checked = false; break; } } } return confirm('Confirm Save?');}\[/code\]client-side\[code\]<asp:TemplateField HeaderText="Default" ItemStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:RadioButton ID="rdbtnDefault" runat="server" onclick="RadioCheck(this);" oncheckedchanged="rdbtnDefault_CheckedChanged" Visible='<%#((string)Eval("DEFAULT")) == "Y" ? false : true %>'/> <asp:Image ID="imgDefault" runat="server" Height="13px" ImageUrl="~/Styles/images/tick-48x48.png" Width="13px" Visible='<% ((string)Eval("DEFAULT")) == "Y" ? true : false %>' /> </ItemTemplate>\[/code\]Server side\[code\]//--Register for in post back--if (Page.ClientScript.IsClientScriptBlockRegistered(DataUCContactListing) == false) { ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "gvRdBtnSelectOnce", blcGenerateScript.gvRdBtnSelectOnce(gvContactPersonList.ClientID,true), true); ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "gvSelectAllChkBox", blcGenerateScript.gvSelectAllChkBox(gvContactPersonList.ClientID), true);}//**Register for script**protected void rdbtnDefault_CheckedChanged(object sender, EventArgs e) { try { RadioButton lnBTNDone = (RadioButton)sender; GridViewRow row = (GridViewRow)lnBTNDone.NamingContainer; string accountID = gvContactPersonList.DataKeys[row.RowIndex].Values[0].ToString(); int contactID = int.Parse(gvContactPersonList.DataKeys[row.RowIndex].Values[1].ToString()); using (TransactionScope scope = new TransactionScope()) { dlcCustomerDB.updateAccountOtherDefaultN(accountID); dlcCustomerDB.updateAccountDefaultY(accountID, contactID); scope.Complete(); } createGridView(); this.Session[gbcMessageSessionID.message1] = gbcMessageAlert.saveSuccessfully; Response.Redirect(Request.Url.ToString()); } catch (Exception ex) { logger.Error(ex.Message); throw; }}\[/code\]