Hi itsjayshah,
I have created a sample which full fill your requirement you need to modify the according to your need.
HTML
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<br />
<br />
<asp:Label ID="lblDismissed" ForeColor="Green" Font-Bold="true" Font-Italic="true"
runat="server" />
<asp:Timer ID="tmAppointmentTimer" Interval="5000" runat="server" OnTick="CheckAppointment">
</asp:Timer>
<div class="modal" id="myModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">
Event Details
</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="caption">
EventName:- <b>
<asp:Label ID="lblEventName" runat="server"></asp:Label></b>
<br />
EventDescription:- <b>
<asp:Label ID="lblEventDescription" runat="server" /></b>
</div>
</div>
</div>
<div class="modal-footer">
<asp:Button ID="Button1" Text="Dismiss" OnClick="Dismiss" class="btn btn-info" runat="server" />
</div>
</div>
</div>
</div>
<div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<script type="text/javascript">
function CloseAppointMent() {
$('[id*=myModal]').modal('hide');
$("[class*='modal-backdrop in']").remove();
}
</script>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
lblDismissed.Text = "Checking whether any event present or not.";
}
}
protected void Dismiss(object sender, EventArgs e)
{
if (ViewState["Data"] != null)
{
DataTable dt = ViewState["Data"] as DataTable;
int index = new System.Data.DataView(dt).ToTable(false, new[] { "EventName" })
.AsEnumerable()
.Select(row => row.Field<string>("EventName"))
.ToList()
.FindIndex(col => col == lblEventName.Text);
dt.Rows[index]["Status"] = "Dismissed";
dt.AcceptChanges();
ViewState["Data"] = dt;
lblDismissed.Text = "You have Dismissed the Event";
string script = "function pageLoad(sender, args) { if (args.get_isPartialLoad()) {CloseAppointMent(); }}";
ScriptManager.RegisterStartupScript(this, GetType(), "AppointMent", script, true);
}
}
protected void CheckAppointment(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("EventName");
dt.Columns.Add("EventDescription");
dt.Columns.Add("EventDate");
dt.Rows.Add("EventName 1", "EventDescription 1", "3/28/2017");
dt.Rows.Add("EventName 2", "EventDescription 2", "3/10/2017");
dt.Rows.Add("EventName 3", "EventDescription 3", "3/12/2017");
dt.Rows.Add("EventName 4", "EventDescription 4", "3/9/2017");
dt.Rows.Add("EventName 5", "EventDescription 5", "3/6/2017");
dt.Columns.Add("Status");
if (ViewState["Data"] == null)
{
ViewState["Data"] = dt;
}
else
{
dt = ViewState["Data"] as DataTable;
}
for (int i = 0; i < dt.Rows.Count; i++)
{
string datetime = DateTime.Now.ToShortDateString();
if (datetime == dt.Rows[i]["EventDate"].ToString() && dt.Rows[i]["Status"].ToString() != "Dismissed")
{
lblEventName.Text = dt.Rows[i]["EventName"].ToString();
lblEventDescription.Text = dt.Rows[i]["EventDescription"].ToString();
string script = "function pageLoad(sender, args) { if (args.get_isPartialLoad()) {$('[id*=myModal]').modal('show'); }}";
ScriptManager.RegisterStartupScript(this, GetType(), "AppointMent", script, true);
break;
}
}
}
Screenshot