Hi AbdulHaque,
Refer the modified sample code.
HTML
<%@ Page Title="" Language="C#" MasterPageFile="~/Fixed_Header_Menu.master" AutoEventWireup="true" CodeFile="Balance.aspx.cs" Inherits="Balance" EnableEventValidation="false" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<script language="javascript" type="text/javascript">
function printdiv(printpage) {
var headstr = "<html><head><title></title></head><body>";
var footstr = "</body>";
var newstr = document.all.item(printpage).innerHTML;
var oldstr = document.body.innerHTML;
document.body.innerHTML = headstr + newstr + footstr;
window.print();
document.body.innerHTML = oldstr;
return false;
}
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js" type="text/javascript"></script>
<link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/blitzer/jquery-ui.css"
rel="stylesheet" type="text/css" />
<script type="text/javascript">
function openPopup(Full_Name, Contact_No) {
$('[id*=lblName]').text(Full_Name);
$('[id*=lblMobile]').text(Contact_No);
$("#popupdiv").dialog({
title: "Send SMS",
width: 300,
height: 250,
modal: true,
open: function (type, data) { $(this).parent().appendTo("form"); },
buttons: {
Ok: function () {
__doPostBack("<%= Button1.UniqueID %>", JSON.stringify({ Name: $('[id*=lblName]').text(), Mobile: $('[id*=lblMobile]').text() }));
},
Close: function () {
$(this).dialog('close');
}
}
});
}
</script>
<style type="text/css">
.GridviewDiv {
font-size: 100%;
font-family: 'Lucida Grande', 'Lucida Sans Unicode', Verdana, Arial, Helevetica, sans-serif;
color: #303933;
}
.headerstyle {
color: #FFFFFF;
border-right-color: #abb079;
border-bottom-color: #abb079;
background-color: #df5015;
padding: 0.5em 0.5em 0.5em 0.5em;
text-align: center;
}
</style>
<style>
.valerr {
color: red;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div id="content" class="bg-container fixed_header_menu_conainer fixed_header_menu_page">
<header class="head">
<div class="main-bar row">
<div class="col-lg-5">
<h4 class="nav_top_align"><i class="fa fa-th"></i> APPLICANT SEARCH</h4>
</div>
<div class="col-lg-7">
<ul class="breadcrumb float-xs-right nav_breadcrumb_top_align">
<li class=" breadcrumb-item">
<a href="index.html">
<i class="fa fa-home" data-pack="default" data-tags=""></i> Dashboard
</a>
</li>
<li class=" breadcrumb-item">
<a href="#">Forms</a>
</li>
<li class="breadcrumb-item active">Balance History</li>
</ul>
</div>
</div>
</header>
<!--//header-->
<!-- #content -->
<div class="outer">
<div class="inner bg-container forms">
<%--<asp:UpdatePanel ID="UpdatePanel1" runat="server">--%>
<%-- <ContentTemplate>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>--%>
<!--Grid-->
<div class="row">
<div class="col-xl-12">
<div class="card m-t-35">
<div class="card-header bg-white">
Find Applicant
</div>
<div class="card-block">
<div class="form-horizontal">
<!--//Top Search Area-->
<div id="AppJrnyPrint">
<h3>
<center>
Balance Details</center>
<h3></h3>
<br />
<!--Pop Modal-->
<div>
<%-- <form id="form1">--%>
<div id="popupdiv" title="Basic modal dialog" style="display: none">
Name:
<label id="lblName"></label>
<%--<asp:Label ID="lblName" runat="server" Text=""></asp:Label>--%>
<br />
Mobile:
<label id="lblMobile"></label>
<%--<asp:Label ID="lblMobile" runat="server" Text=""></asp:Label>--%>
<br />
Message:
<asp:TextBox ID="txtMessage" runat="server" Placeholder="Type your message here...!" TextMode="MultiLine"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" Style="display: none" OnClick="Button1_Click" />
</div>
<%-- </form>--%>
<!--END-->
<!--Gridview for Apllicant-->
<div class="row form-group">
<div class="table-responsive">
<asp:GridView ID="grdSummary" runat="server" AutoGenerateColumns="false" CssClass="table table-striped table-bordered table-hover"
HorizontalAlign="Center" OnSelectedIndexChanged="grdSummary_SelectedIndexChanged"
OnRowCommand="GridView1_RowCommand" ShowFooter="true">
<Columns>
<%--<asp:BoundField DataField="SL.No" HeaderText="SL.No" />--%>
<asp:TemplateField HeaderText="Serial No">
<ItemTemplate>
<%#Container.DataItemIndex+1 %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Applicant Name">
<ItemTemplate>
<asp:Label ID="TextBox1" runat="server" Text='<%#Bind("Full_Name")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Service Name">
<ItemTemplate>
<asp:Label ID="TextBox2" runat="server" Text='<%#Bind("SS_Desc")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date">
<ItemTemplate>
<asp:Label ID="TextBox3" runat="server" Text='<%#Bind("DateTime","{0:dd MMM yyyy}")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Phone No">
<ItemTemplate>
<asp:Label ID="TextBox4" runat="server" Text='<%#Bind("Contact_No")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total Amount">
<ItemTemplate>
<asp:Label ID="TextBox5" runat="server" Text='<%#Bind("CommitmentAmount")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Discount">
<ItemTemplate>
<asp:Label ID="TextBox6" runat="server" Text='<%#Bind("DiscountAmount")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Paid">
<ItemTemplate>
<asp:Label ID="TextBox7" runat="server" Text='<%#Bind("paid")%>'></asp:Label>
</ItemTemplate>
<FooterStyle HorizontalAlign="Right" />
<FooterTemplate>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Balance">
<ItemTemplate>
<asp:Label ID="TextBox8" runat="server" Text='<%#Bind("bal")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Send SMS">
<ItemTemplate>
<a href="#" class="gridViewToolTip" onclick='openPopup("<%# Eval("Full_Name")%>","<%# Eval("Contact_No")%>")'>Click Here</a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>
</div>
</h3>
</div>
<br />
<%--<asp:button id="backButton" class="btn btn-responsive layout_btn_prevent btn-primary form-control" style="width: 100px;" runat="server" text="Back" OnClientClick="JavaScript:window.history.back(1);return false;"></asp:button>--%>
<input type="button" class="btn btn-responsive layout_btn_prevent btn-primary form-control"
style="width: 100px;" value="Print" onclick="printdiv('AppJrnyPrint');" />
<asp:Calendar ID="Calendar1" runat="server" Visible="false"></asp:Calendar>
</div>
</div>
</div>
</div>
</div>
<%--</ContentTemplate>
</asp:UpdatePanel>--%>
</div>
</div>
</div>
</asp:Content>
C#
using System;
using System.Data;
using System.IO;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Balance : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ClientScript.GetPostBackEventReference(this, string.Empty);
if (!IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] {
new DataColumn("Id"), new DataColumn("Full_Name"), new DataColumn("SS_Desc"),
new DataColumn("DateTime",typeof(DateTime)), new DataColumn("Contact_No"), new DataColumn("CommitmentAmount"),
new DataColumn("DiscountAmount"), new DataColumn("paid"), new DataColumn("bal")});
dt.Rows.Add(1, "Name 1", "Test 1", "11/11/2017", "1111111111", "100", "10", "85", "5");
dt.Rows.Add(2, "Name 2", "Test 2", "11/11/2017", "2222222222", "200", "10", "180", "10");
dt.Rows.Add(3, "Name 3", "Test 3", "11/11/2017", "3333333333", "300", "10", "280", "10");
dt.Rows.Add(4, "Name 4", "Test 4", "11/11/2017", "4444444444", "400", "10", "185", "5");
grdSummary.DataSource = dt;
grdSummary.DataBind();
}
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Select")
{
//Determine the RowIndex of the Row whose Button was clicked.
int rowIndex = Convert.ToInt32(e.CommandArgument);
//Reference the GridView Row.
GridViewRow row = grdSummary.Rows[rowIndex];
//Fetch value of Name.
string numb = (row.FindControl("TextBox4") as Label).Text;
//ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Mobile: " + numb + "');", true);
}
}
protected void grdSummary_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string name, ph, msg;
using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(Request["__EVENTARGUMENT"])))
{
DataContractJsonSerializer deserializer = new DataContractJsonSerializer(typeof(SmsDetails));
SmsDetails bsObj2 = (SmsDetails)deserializer.ReadObject(ms);
name = bsObj2.Name;
ph = bsObj2.Mobile;
}
msg = txtMessage.Text;
ClientScript.RegisterStartupScript(Page.GetType(), "key", "alert('Name: " + name + "\\n\\rMobile: " + ph + "\\n\\rMessage: " + msg + "')", true);
}
public class SmsDetails
{
public string Name { get; set; }
public string Mobile { get; set; }
}
}