Hi alya14,
You can use javascript confirmation message box for the same which will work in Hosted Site too.
I have created a sample which full your requriement you need to modify the code according to your need.
HTML
<div>
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chkboxid" runat="server" onclick="toggleSelectionGrid(this);" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<asp:Button ID="Button1" runat="server" OnClick="Query_Click" Text="QUERY" />
<asp:Button ID="btnSendMail" OnClick="SendMail" runat="server" Text="SEND" />
<br />
</div>
<div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
function toggleSelectionGrid(source) {
var isChecked = source.checked;
$("#GridView1 input[id*='chkboxid']").each(function (index) {
$(this).attr('checked', false);
});
source.checked = isChecked;
}
$(function () {
$('[id*=btnSendMail]').click(function () {
var checkbox = "";
$('[id*=GridView1] tr').each(function () {
var row = $(this).closest('tr');
var chkboxid = row.find('[id*=chkboxid]');
if ($(chkboxid).is(':checked')) {
checkbox = chkboxid;
}
});
if ($(checkbox).is(':checked')) {
var row = $(checkbox).closest('tr');
var country = row.find('td').eq(3).html();
var value = confirm('Do u want the start service for ' + country + '?');
if (value) {
return true;
}
else {
alert('You Have Stopped the Service');
}
}
else {
alert('Please Select AtLeast one checkbox from GridView');
}
return false;
});
});
</script>
</div>
C#
protected void Query_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] { new DataColumn("Id"), new DataColumn("Name"), new DataColumn("Country") });
dt.Rows.Add(1, "John Hammond", "United States");
dt.Rows.Add(2, "Mudassar Khan", "India");
dt.Rows.Add(3, "Suzanne Mathews", "France");
dt.Rows.Add(4, "Robert Schidner", "Russia");
//Bind your Gridview with database records.
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void SendMail(object sender, EventArgs e)
{
//Proceed with your further Process.
ClientScript.RegisterStartupScript(this.GetType(), "Start", "alert('Your Service Started')", true);
}
VB.Net
Protected Sub Query_Click(sender As Object, e As EventArgs)
Dim dt As New DataTable()
dt.Columns.AddRange(New DataColumn() {New DataColumn("Id"), New DataColumn("Name"), New DataColumn("Country")})
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
'Bind your Gridview with database records.
GridView1.DataSource = dt
GridView1.DataBind()
End Sub
Protected Sub SendMail(sender As Object, e As EventArgs)
'Proceed with your further Process.
ClientScript.RegisterStartupScript(Me.[GetType](), "Start", "alert('Your Service Started')", True)
End Sub
ScreenShot