Hi @Simflex,
The function of popping up a warning message can refer to the following code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script>
$(document).ready(function () {
$('input[type=checkbox]').click(function () {
var areYouSure = confirm('Are you sure you want to clean the data?');
if (areYouSure) {
$(this).prop('checked', this.checked);
} else {
$(this).prop('checked', !this.checked);
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="grvCred" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Name">
<HeaderStyle HorizontalAlign="Left" />
<ItemTemplate>
<asp:TextBox ID="txtcreditorname" Text='<%# Eval("creditorname") %>' placeholder="Name of creditor..." runat="server" Style="width: 375px;" class="form-control" AutoPostBack="true" OnTextChanged="txtcreditorname_TextChanged"></asp:TextBox><br />
<asp:CheckBox ID="credChk" runat="server" AutoPostBack="true" OnCheckedChanged="CredCheckChanged" /><span style="color: #ff0000">*Check this box if N/A</span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<ItemStyle HorizontalAlign="Left"></ItemStyle>
<ItemTemplate>
<asp:TextBox ID="txtcreditoraddress" Text='<%# Eval("creditoraddress") %>' placeholder="Address..." runat="server" Style="width: 375px;" class="form-control" AutoPostBack="true" OnTextChanged="txtcreditorname_TextChanged"></asp:TextBox><br />
<br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
Protected Sub CredCheckChanged(ByVal sender As Object, ByVal args As EventArgs)
Dim selRowIndex As Integer = (CType(((CType(sender, CheckBox)).Parent.Parent), GridViewRow)).RowIndex
Dim cb As CheckBox = CType(grvCred.Rows(selRowIndex).FindControl("credChk"), CheckBox)
Dim credname As TextBox = CType(grvCred.Rows(selRowIndex).FindControl("txtcreditorname"), TextBox)
Dim credaddress As TextBox = CType(grvCred.Rows(selRowIndex).FindControl("txtcreditoraddress"), TextBox)
If cb.Checked Then
credname.Text = ""
credaddress.Text = ""
cb.Checked = False
End If
End Sub
Protected Sub txtcreditorname_TextChanged(ByVal sender As Object, ByVal e As EventArgs)
For Each row As GridViewRow In grvCred.Rows
Dim credname As TextBox = TryCast(row.FindControl("txtcreditorname"), TextBox)
Dim credaddress As TextBox = TryCast(row.FindControl("txtcreditoraddress"), TextBox)
Dim credSelect As CheckBox = TryCast(row.FindControl("credChk"), CheckBox)
If credname.Text.Length > 0 AndAlso credaddress.Text.Length > 0 Then
credSelect.Enabled = False
Else
credSelect.Enabled = True
End If
Next
End Sub
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.