Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The gridview have radio button i want to show confirm message after radio button selected.


Code:


try
{
for (int i = 0; i; grdLanguagedesc.Rows.Count; i++)
{

RadioButton rb = (RadioButton)grdLanguagedesc.Rows[i].FindControl("RowSelector");
if (rb.Checked == true)
{
//Page.ClientScript.RegisterStartupScript(this.GetType(), clientScript, return confirm('Are you sure you want to delete this record?');, true);
//ScriptManager.RegisterStartupScript(this, this.GetType(), clientScript, confirm_delete();, true);
//Page.ClientScript.RegisterStartupScript(this.GetType(), clientScript, javascript:if(!confirm('Do you wish to complete this order?')) return false;);
string msgid = grdLanguagedesc.Rows[i].Cells[1].Text;
DeleteRecords(msgid);
lblError.Visible = true;
return;
else
{
lblError.Visible = true;
lblError.Text = Please Select Record in GridView;
btnSearch.Focus();
lnkfilter.Focus();

}
}
}



<b>
How to show the confirm message before delete Grid view record when you click delete button outside the gridview?</b>
Posted

Add OnClientClick javascript function for the button and show the confirm button and return true only if user confirmed it.
 
Share this answer
 
v2
1. Write an event handler for the Grid itemdatabound/rowdatabound event.
2. Inside that eventhandler, find each radio button using FindControl method.
3. add an javascript function in attributes collection of radion button control. Dont forget to write "return" as follows

RadioButton rd = FindControl...

rd.attributes.add("onclick","return ShowAlert(this.id)");

4. Write a javascript function ShowAlert() as follows

function ShowAlert()
{
   var response = Confirm("Want to proceed?")
   if(response)
   return true;
    else
   return false;
}


Hope it helps you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900