Description:-
In this example we explain that how to load html
page in div tag dynamically using jquery in asp.net.or dynamically load page in
DIV using jquery in asp.net.
Here we use jquery Load () method to load page dynamically
inside the DIV tag using jquery. Generally Load () method load the data form
the server and that data you can put inside any element in jquery.
LoadFile.aspx:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LoadFile.aspx.cs" Inherits="LoadFile" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#<%=btn_load.ClientID%>').click(function () {
$('#container').load("grid.aspx");
return false;
});
});
</script>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btn_load" runat="server" Text="Load Data" />
<fieldset style="width:50px">
<legend>
<b>Data Load from the Grid.aspx page.</b>
</legend>
<div id="container"></div>
</fieldset>
</div>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="grid.aspx.cs" Inherits="grid" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2">
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FFF1D4" />
<SortedAscendingHeaderStyle BackColor="#B95C30" />
<SortedDescendingCellStyle BackColor="#F1E5CE" />
<SortedDescendingHeaderStyle BackColor="#93451F" />
</asp:GridView>
</div>
</form>
</body>
</html>
using
System;
using
System.Collections.Generic;
using
System.Data;
using
System.Data.SqlClient;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
public partial class grid : System.Web.UI.Page
{
protected void Page_Load(object
sender, EventArgs e)
{
string CS = @"your
connectionstring";
using (SqlConnection con = new SqlConnection(CS))
{
SqlCommand cmd = new SqlCommand("select * from tbl_notification
where noti_Status=0", con);
con.Open();
SqlDataAdapter sa = new SqlDataAdapter();
DataTable dt = new DataTable();
sa.SelectCommand = cmd;
cmd.ExecuteNonQuery();
sa.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
}
0 comments:
Post a Comment