1) Simpler If you want to add an authentication script to a button, you can do this Copy the code Code As follows: <%@ Page Language="C#" %><br><br>function getconfirm ()<br> {<br> if (confirm("Do you want to delete record?")==true) <br> return true;<br> else<br> return false; <br><br>}<br>< /SCRIPT><br><br><script runat="server"><br>public void Page_Load(Object sender, EventArgs E) {<br>btnSubmit.Attributes.Add("onclick","return getconfirm ( );");<br>}<br>void btnSubmit_Click(object sender, EventArgs e) {<br> Message.Text = "You entered your name as: " txtName.Text;<br>}<br>< /script><br><html><br><head><br></head><br><body><br><form runat="server"><br> Name: <asp:Textbox id="txtName" runat="server"/><br><asp:Button id="btnSubmit" onclick="btnSubmit_Click" runat="server" Text="Submit">< /asp:Button><br/><br><asp:Label id="Message" runat="server"/><br></form><br></body><br></html> <br> </div> <br>Pay attention to the key point btnSubmit.Attributes.Add("onclick","return fffkkk();"); This sentence is equivalent to the static page tag Add "onclick = "return fffkkk();" Same as <br> 2) A little more complicated <br> Sometimes we need to add authentication to the delete column of DataGrid, you can do this <br> First create a DataGrid, and then give it to her Add a delete column <br><br> <div class="codetitle"> <span><a style="CURSOR: pointer" data="88394" class="copybut" id="copybut88394" onclick="doCopy('code88394')"><u> Copy the code </u></a></span> The code is as follows: </div> <div class="codebody" id="code88394"> <br><asp:DataGrid id="DataGrid1" runat="server"><br><Columns><br><asp:TemplateColumn><br> <ItemTemplate><br><asp:LinkButton id="cmdDel" <BR>runat="server" Text="Delete" <BR>CommandName="Delete" CausesValidation="false"><br></asp:LinkButton><br> </ItemTemplate><br></ asp:TemplateColumn><br></Columns><br></asp:DataGrid><br> </div> <p>Then write this in the ItemDataBound event of the DataGrid <br></p> <div class="codetitle"> <span><a style="CURSOR: pointer" data="66368" class="copybut" id="copybut66368" onclick="doCopy('code66368')"><u>Copy the code </u></a></span> The code is as follows: </div> <div class="codebody" id="code66368"> <br> Private Sub DataGrid1_ItemDataBound<br>(ByVal sender As Object, ByVal e As DataGridItemEventArgs) <br>Handles DataGrid1.ItemDataBound<br> Dim l As LinkButton<br> If e.Item.ItemType = ListItemType.Item Or <br> e. Item.ItemType = ListItemType.AlternatingItem Then<br> l = CType(e.Item.Cells(0).FindControl("cmdDel"), LinkButton)<br> l.Attributes.Add("onclick", "return getconfirm( );")<br> End If<br>End Sub<br>Getconfirm() function is the same as the first one <br>function getconfirm() <br>{ <br>if (confirm("Do you want to delete record?")==true) <br>return true; <br>else <br>return false; <br>}<br> </div>