File->New->WebSite
Master Page Design
Design
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div>
<table>
<tr>
<td>Uday Blog Spot
</td>
<td>http://dotnetbyudayrajakonda.blogspot.in/
</td>
</tr>
<tr>
<td colspan="2">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
</td>
</tr>
</table>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
</asp:UpdatePanel>
<asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick"></asp:Timer>
</div>
<div class='popup' style="position: fixed; margin-right: 50px; width: 300px; height: 200px" id="divRemainder">
</div>
</form>
</body>
styles
<style type="text/css">
.popup{
background-color: #F4F4F4;
border: 7px solid #545353 !important;
border-radius: 5px 5px 5px 5px;
-webkit-box-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
-moz-box-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
box-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
display: none;
}
.content {
min-width: 600px;
width: 600px;
min-height: 150px;
margin: 100px auto;
background: #f3f3f3;
position: relative;
z-index: 103;
padding: 10px;
border-radius: 5px;
box-shadow: 0 2px 5px #000;
margin-right: 42%;
}
</style>
java script function
<script type="text/javascript">
function myFunction() {
var string = MasterPage2.RemainderDetails();
$('#divRemainder').append(string.value);
$('.popup').show();
return false;
}
</script>
MasterPage.cs
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
public string RemainderDetails()
{
SqlConnection con = new SqlConnection("");
SqlCommand cmd = new SqlCommand("", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
DataTable _dataTable = ds.Tables[0];
StringBuilder sb = new StringBuilder();
int count = _dataTable.Rows.Count;
if (count > 0)
{
sb.Append("<table width='100%' cellspacing='0' cellpadding='0' border='0'>");
sb.Append("<thead class='tableHeadBg'><tr>");
sb.Append("</tr></thead>");
sb.Append("<tbody class='tableTbodyBg'>");
for (int i = 0; i < count; i++)
{
sb.Append("<tr>");
sb.Append("<td width='10%' align='left'>");
sb.Append(Convert.ToString(_dataTable.Rows[i]["Appointment"]));
sb.Append("</td>");
sb.Append("<td width='10%' align='left'>");
sb.Append(Convert.ToString(_dataTable.Rows[i]["RemainderStartDate"]));
sb.Append("</td>");
sb.Append("</tr>");
}
sb.Append("</tbody></table>");
}
return sb.ToString();
}
Add Content Page as Follows
Content Page
contentPage.cs(Need not write any code in Default Page as the code need to be written in Master Page.
Design
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div>
<table>
<tr>
<td>Uday Blog Spot
</td>
<td>http://dotnetbyudayrajakonda.blogspot.in/
</td>
</tr>
<tr>
<td colspan="2">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
</td>
</tr>
</table>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
</asp:UpdatePanel>
<asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick"></asp:Timer>
</div>
<div class='popup' style="position: fixed; margin-right: 50px; width: 300px; height: 200px" id="divRemainder">
</div>
</form>
</body>
styles
<style type="text/css">
.popup{
background-color: #F4F4F4;
border: 7px solid #545353 !important;
border-radius: 5px 5px 5px 5px;
-webkit-box-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
-moz-box-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
box-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
display: none;
}
.content {
min-width: 600px;
width: 600px;
min-height: 150px;
margin: 100px auto;
background: #f3f3f3;
position: relative;
z-index: 103;
padding: 10px;
border-radius: 5px;
box-shadow: 0 2px 5px #000;
margin-right: 42%;
}
</style>
java script function
<script type="text/javascript">
function myFunction() {
var string = MasterPage2.RemainderDetails();
$('#divRemainder').append(string.value);
$('.popup').show();
return false;
}
</script>
MasterPage.cs
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
public string RemainderDetails()
{
SqlConnection con = new SqlConnection("");
SqlCommand cmd = new SqlCommand("", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
DataTable _dataTable = ds.Tables[0];
StringBuilder sb = new StringBuilder();
int count = _dataTable.Rows.Count;
if (count > 0)
{
sb.Append("<table width='100%' cellspacing='0' cellpadding='0' border='0'>");
sb.Append("<thead class='tableHeadBg'><tr>");
sb.Append("</tr></thead>");
sb.Append("<tbody class='tableTbodyBg'>");
for (int i = 0; i < count; i++)
{
sb.Append("<tr>");
sb.Append("<td width='10%' align='left'>");
sb.Append(Convert.ToString(_dataTable.Rows[i]["Appointment"]));
sb.Append("</td>");
sb.Append("<td width='10%' align='left'>");
sb.Append(Convert.ToString(_dataTable.Rows[i]["RemainderStartDate"]));
sb.Append("</td>");
sb.Append("</tr>");
}
sb.Append("</tbody></table>");
}
return sb.ToString();
}
Add Content Page as Follows
Content Page
contentPage.cs(Need not write any code in Default Page as the code need to be written in Master Page.
\
Output: