using javascript confirmation box in gridview asp.net
-
hi I have a gridview and a delete button inside it. I want to show a javascript confirmation dialogue box on the click of this button . How can achieve this.? waiting ur reply . thanx sandeep
-
hi I have a gridview and a delete button inside it. I want to show a javascript confirmation dialogue box on the click of this button . How can achieve this.? waiting ur reply . thanx sandeep
-
hi I have a gridview and a delete button inside it. I want to show a javascript confirmation dialogue box on the click of this button . How can achieve this.? waiting ur reply . thanx sandeep
These are the steps you need to follow Step1:In your form example(form1.aspx.cs)put this code remember it soould be protected void protected void Imagebutton10_Click(object sender, System.Web.UI.ImageClickEventArgs e) { this.Page.RegisterStartupScript("SetConfirm", "window.Form1['DisplayConfirm'].value=true;"); this.Page.RegisterStartupScript("SetConfirm", "window.Form1['DisplayConfirm'].value=false;"); ImageButton Imagebutton=(ImageButton)sender; DataGridItem dgi=(DataGridItem)Imagebutton.Parent.Parent; ViewState["BookMarkID"]=this.dg_SearchCondition.Items[dgi.DataSetIndex].Cells[5].Text; } Step2:In HTML of your page Paste this code onclick="Imagebutton10_Click" runat="server" ImageUrl="image\delete.bmp"> Step3: Declear a java script function in your HTML function displayMessage() { if(window.Form1["DisplayConfirm"].value==true || window.Form1["DisplayConfirm"].value=="true") { if(confirm(" Do you want to delete?")==true) { window.Form1["Button3"].click(); } } Step4: Call this function on form body load onload="displayMessage();" step5:Take a button named "Button3" on ur page make it small so that it sould not be visible on page load. step6:Take HTML Hidden text box with name example on your page Rizwan Afsar Associate Member, Technical Team IAP Company Ltd, Gurgaon -- modified at 7:59 Tuesday 4th April, 2006