Master page code:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Admin.master.cs" Inherits="SSTeleCallerApp.AdminPanel.Admin" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta charset="utf-8"/>
<title>Taxi Booking Application</title>
<link rel="stylesheet" href="../css/layout1.css" type="text/css" media="screen" />
<!--[if lt IE 9]>
<link rel="stylesheet" href="css/ie.css" type="text/css" media="screen" />
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="../js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="../js/hideshow.js" type="text/javascript"></script>
<script src="../js/jquery.tablesorter.min.js" type="text/javascript"></script>
<script type="text/javascript" src="../js/jquery.equalHeight.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(".tablesorter").tablesorter();
}
);
$(document).ready(function () {
//When page loads...
$(".tab_content").hide(); //Hide all content
$("ul.tabs li:first").addClass("active").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content
//On Click Event
$("ul.tabs li").click(function () {
$("ul.tabs li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".tab_content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active ID content
return false;
});
});
</script>
<script type="text/javascript">
$(function () {
$('.column').equalHeight();
});
</script>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<header id="header">
<hgroup>
<h1 class="site_title"><a href="DriverMaster.aspx">Admin</a></h1>
</hgroup>
</header> <!-- end of header bar -->
<section id="secondary_bar">
<div class="user">
<p> </p>
<!-- <a class="logout_user" href="#" title="Logout">Logout</a> -->
</div>
<div class="breadcrumbs_container">
</div>
</section><!-- end of secondary bar -->
<aside id="sidebar" class="column">
<hr/>
<ul><b>
<li><a href="DriverMaster.aspx" style="padding-left:0px">Drive Master</a></li>
<li><a href="LocationMaster.aspx" style="padding-left:0px">Location Master</a></li>
<li><a href="#" style="padding-left:0px">Cab Master</a></li>
<li><a href="#" style="padding-left:0px">Telecaller Master</a></li>
<li><a href="#" style="padding-left:0px">Cab Type Master</a></li>
<li><a href="#" style="padding-left:0px">Trip Type Master</a></li>
<li><a href="#" style="padding-left:0px">Branch Master</a></li>
<li><a href="#" style="padding-left:0px">Customer Master</a></li>
<li><a href="#" style="padding-left:0px">Report</a></li>
</ul></b>
<footer>
<hr style="margin-top:294px" />
<p style=" "><strong>Copyright © 2016 Keni Technologies</strong></p>
<p>Theme by <a href="http://www.kenitechnologies.com">Keni Technologies</a></p>
</footer>
</aside><!-- end of sidebar -->
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</form>
</body>
</html>
Child Page:
<%@ Page Title="" Language="C#" MasterPageFile="~/AdminPanel/Admin.Master" AutoEventWireup="true"
CodeBehind="BranchMaster.aspx.cs" Inherits="SSTeleCallerApp.AdminPanel.BranchMaster" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<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/start/jquery-ui.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$("[id*=btnadd]").live("click", function () {
debugger;
$("#modal_dialog").dialog({
title: "Manage Branch",
autoopen: false,
width: 500,
buttons: {
ADD: function () {
$("#<%= add%>").click();
$(this).dialog('close');
},
Cancel: function () {
$(this).dialog('close');
}
},
modal: true
});
return false;
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:Button ID="btnadd" runat="server" Text="Add Branch" style="float:right" />
<section id="main" class="column">
<article class="module width_4_quarter" style=" height:316px; margin-top:5px">
<header><h3 class="tabs_involved">Branch Master</h3>
</header>
<div class="tab_container">
<div id="tab" class="tab_content">
<asp:GridView ID="grdbranch" runat="server" class="tablesorter" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" />
<asp:BoundField DataField="Branch" HeaderText="Branch" />
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="false" CommandName="" Text="EDIT" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:Button ID="Button2" runat="server" CausesValidation="false" CommandName="" Text="DELETE" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<!-- end of #tab1 -->
</div>
<!-- ID -->
<div id="modal_dialog" style="display: none">
<div class="tab_container">
<div id="tab2" class="tab_content">
<table class="tablesorter" cellspacing="0">
<tbody>
<tr>
<td>
<b>ID:
<asp:TextBox ID="TextBox1" runat="server" Style="margin-left: 130px"></asp:TextBox>
<br />
<br />
Branch:
<asp:TextBox ID="TextBox2" runat="server" Style="margin-left: 97px"></asp:TextBox>
<br />
<br />
</td>
</tr>
</tbody>
<asp:Button ID="add" runat="server" Text="ADD" style="display:none" OnClick="btninsert_Click"></asp:Button>
</table>
</div>
<!-- end of #tab1 -->
</div>
<!-- ID -->
</div>
</section>
</asp:Content>
Backend coding
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
namespace SSTeleCallerApp.AdminPanel
{
public partial class BranchMaster : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGridview();
}
}
protected void BindGridview()
{
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=WINCTRL-TNT3FMR;Initial Catalog=TaxiAPP;Integrated Security=True";
con.Open();
string sql = "select ID,Branch from Branch";
SqlDataAdapter ad = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
ad.Fill(ds);
grdbranch.DataSource = ds;
grdbranch.DataBind();
}
protected void btninsert_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=WINCTRL-TNT3FMR;Initial Catalog=TaxiAPP;Integrated Security=True";
SqlCommand command = new SqlCommand("Insert into Branch(ID,Branch)values(@ID,@Branch)SELECT SCOPE_IDENTITY()", con);
con.Open();
command.Parameters.AddWithValue("@ID", TextBox1.Text);
command.Parameters.AddWithValue("@Branch", TextBox2.Text);
command.ExecuteNonQuery();
con.Close();
}
}
}