add script on ur page
script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script
script type="text/javascript">
$(document).ready(function () {
$('#btn').click(function () {
$.ajax({
contentType: "text/html; charset=utf-8",
data: "EID=" + $('#tb').val() + "&NAME=" + $('#tb1').val(),
url: "Default3.aspx",
dataType: "html",
async: false,
success: function (data) {
$("#dv").html(data);
$("#lb1").text('One record saved.')
}
});
});
});
</script
design the page like this,this code write inside the form tag.
center>
div style="width:940px;">
li style="width:360px; list-style:none; text-align:right; float:left; padding-top:3px"> </li>
li style="width:20px; list-style:none; float:left; padding-top:3px; text-align:center; font-weight:bolder"> </li
li style="width:560px; list-style:none; text-align:left; float:left; padding-top:3px"> <asp:Label ForeColor="Green" ID="lb1" runat="server" EnableViewState="false"></asp:Label></li>
li style="width:360px; list-style:none; text-align:right; float:left; padding-top:3px">EID</li>
li style="width:20px; list-style:none; float:left; padding-top:3px; text-align:center; font-weight:bolder">:</li>
li style="width:560px; list-style:none; text-align:left; float:left; padding-top:3px"><asp:TextBox ID="tb" runat="server"></asp:TextBox></li>
li style="width:360px; list-style:none; text-align:right; float:left; padding-top:3px">Name</li>
<li style="width:20px; list-style:none; float:left; padding-top:3px; text-align:center; font-weight:bolder">:</li>
<li style="width:560px; list-style:none; text-align:left; float:left; padding-top:3px"><asp:TextBox ID="tb1" runat="server"></asp:TextBox></li>
li style="width:360px; list-style:none; text-align:right; float:left; padding-top:3px"> </li>
li style="width:20px; list-style:none; float:left; padding-top:3px; text-align:center; font-weight:bolder"> </li>
<li style="width:560px; list-style:none; text-align:left; float:left; padding-top:3px"><input type="button" id="btn" value="Save" style="width:80px"><asp:Button ID="Button1" runat="server" Text="Reset" Width="80" /></li>
li style="width:360px; list-style:none; text-align:right; float:left; padding-top:3px"> </li>
li style="width:20px; list-style:none; float:left; padding-top:3px; text-align:center; font-weight:bolder"> </li>
li style="width:560px; list-style:none; text-align:left; float:left; padding-top:3px"> <div id="dv"></div></li>
/div>
/center>
page should looks like this
CODE OF DEFAULT3.ASPX ARE :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
public partial class Default3 : System.Web.UI.Page
{
DataClassesDataContext o = new DataClassesDataContext(ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ToString());
protected void Page_Load(object sender, EventArgs e)
{
EMP p = new EMP();
p.EID = Convert.ToInt32(Request.QueryString["EID"].ToString());
p.NAME = Request.QueryString["NAME"].ToString();
o.EMPs.InsertOnSubmit(p);
o.SubmitChanges();
var m = from x in o.EMPs select x;
Response.Write("<table border='1' style='width:500px'><tr><th>EID</th><th>NAME</th></tr>");
foreach (var n in m)
{
Response.Write("<tr><td>"+n.EID+"</td><td>"+n.NAME+"</td></tr>");
}
Response.Write("</table>");
Response.End();
}
}
script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script
script type="text/javascript">
$(document).ready(function () {
$('#btn').click(function () {
$.ajax({
contentType: "text/html; charset=utf-8",
data: "EID=" + $('#tb').val() + "&NAME=" + $('#tb1').val(),
url: "Default3.aspx",
dataType: "html",
async: false,
success: function (data) {
$("#dv").html(data);
$("#lb1").text('One record saved.')
}
});
});
});
</script
design the page like this,this code write inside the form tag.
center>
div style="width:940px;">
li style="width:360px; list-style:none; text-align:right; float:left; padding-top:3px"> </li>
li style="width:20px; list-style:none; float:left; padding-top:3px; text-align:center; font-weight:bolder"> </li
li style="width:560px; list-style:none; text-align:left; float:left; padding-top:3px"> <asp:Label ForeColor="Green" ID="lb1" runat="server" EnableViewState="false"></asp:Label></li>
li style="width:360px; list-style:none; text-align:right; float:left; padding-top:3px">EID</li>
li style="width:20px; list-style:none; float:left; padding-top:3px; text-align:center; font-weight:bolder">:</li>
li style="width:560px; list-style:none; text-align:left; float:left; padding-top:3px"><asp:TextBox ID="tb" runat="server"></asp:TextBox></li>
li style="width:360px; list-style:none; text-align:right; float:left; padding-top:3px">Name</li>
<li style="width:20px; list-style:none; float:left; padding-top:3px; text-align:center; font-weight:bolder">:</li>
<li style="width:560px; list-style:none; text-align:left; float:left; padding-top:3px"><asp:TextBox ID="tb1" runat="server"></asp:TextBox></li>
li style="width:360px; list-style:none; text-align:right; float:left; padding-top:3px"> </li>
li style="width:20px; list-style:none; float:left; padding-top:3px; text-align:center; font-weight:bolder"> </li>
<li style="width:560px; list-style:none; text-align:left; float:left; padding-top:3px"><input type="button" id="btn" value="Save" style="width:80px"><asp:Button ID="Button1" runat="server" Text="Reset" Width="80" /></li>
li style="width:360px; list-style:none; text-align:right; float:left; padding-top:3px"> </li>
li style="width:20px; list-style:none; float:left; padding-top:3px; text-align:center; font-weight:bolder"> </li>
li style="width:560px; list-style:none; text-align:left; float:left; padding-top:3px"> <div id="dv"></div></li>
/div>
/center>
page should looks like this
CODE OF DEFAULT3.ASPX ARE :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
public partial class Default3 : System.Web.UI.Page
{
DataClassesDataContext o = new DataClassesDataContext(ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ToString());
protected void Page_Load(object sender, EventArgs e)
{
EMP p = new EMP();
p.EID = Convert.ToInt32(Request.QueryString["EID"].ToString());
p.NAME = Request.QueryString["NAME"].ToString();
o.EMPs.InsertOnSubmit(p);
o.SubmitChanges();
var m = from x in o.EMPs select x;
Response.Write("<table border='1' style='width:500px'><tr><th>EID</th><th>NAME</th></tr>");
foreach (var n in m)
{
Response.Write("<tr><td>"+n.EID+"</td><td>"+n.NAME+"</td></tr>");
}
Response.Write("</table>");
Response.End();
}
}
No comments:
Post a Comment