This is an an Open Source jQuery Project. I made this project in jQuery. Here I will explain how to make our project in jQuery. The name of my project is R-NoteBook.

The following is my jQuery and aspx code:

  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head runat="server">
  5. <title>R-NoteBook - A jQuery Open Source Project </title>
  6. <script src="jquery-1.10.2.min.js" type="text/javascript"></script>
  7. <style type="text/css">
  8. .tblNoteResult
  9. {
  10. border: solid 7px Red;
  11. }
  12. .tblNoteResult td
  13. {
  14. padding: 5px;
  15. border: 1px solid #2D4CB1;
  16. font-family:Verdana;
  17. font-size:8pt;
  18. background-color:#E6EFF2;
  19. }
  20. .tblNoteResult th
  21. {
  22. padding: 5px;
  23. border: 1px solid green;
  24. background-color:Green;
  25. color:#FCE514;
  26. font-family:Verdana;
  27. font-size:12pt;
  28. }
  29. </style>
  30. <script type="text/javascript">
  31. function bindData() {
  32. $.ajax({
  33. type: "POST",
  34. url: "Default.aspx/getData",
  35. data: "{}",
  36. contentType: "application/json; charset=utf-8",
  37. datatype: "jsondata",
  38. async: "true",
  39. success: function(response) {
  40. if ($('#tblRNoteBookResult').length != 0)
  41. { $("#tblRNoteBookResult").remove(); }
  42. var table = "<table class='tblNoteResult' id=tblRNoteBookResult cellpadding='10' cellspacing='4' width='90%' align='center'><thead> <tr><th align='left'>Note Title</th><th align='left'>Note Description</th><th align='left'>Posted On</th><th align='left'>Posted By</th></thead> <tbody>";
  43. for (var i = 0; i <= response.d.length - 1; i++)
  44. {
  45. var row = "<tr>";
  46. row += '<td width=20%>' + response.d[i].NoteTitle + '</td>';
  47. row += '<td width=50%>' + response.d[i].NoteDesc + '</td>';
  48. row += '<td width=15%>' + response.d[i].PostedDate + '</td>';
  49. row += '<td width=15%>' + response.d[i].PostedBy + '</td>';
  50. row += '</tr>';
  51. table += row;
  52. }
  53. table += '</tbody></table>';
  54. $('#divRNoteBookData').html(table);
  55. $("#divRNoteBookData").slideDown("slow");
  56. },
  57. error: function(response) {
  58. alert(response.status + ' chandan ' + response.statusText);
  59. }
  60. });
  61. }
  62. $(document).ready(function() {
  63. bindData();
  64. $('#btnSubmit').click(function() {
  65. var NoteTitle = $("#txtTitle").val();
  66. var NoteDescription = $("#txtDescription").val();
  67. var PostedBy = $("#txtName").val();
  68. $.ajax({
  69. type: "POST",
  70. url: "Default.aspx/saveData",
  71. data: "{Title:'" + NoteTitle + "',Description:'" + NoteDescription + "',PostedBy:'" + PostedBy + "'}",
  72. contentType: "application/json; charset=utf-8",
  73. datatype: "jsondata",
  74. async: "true",
  75. success: function(response) {
  76. var myObject = eval('(' + response.d + ')');
  77. if (myObject > 0) {
  78. alert("Note Saved Successfully.");
  79. // Binding All Note
  80. bindData();
  81. // Clear All Text Box Values
  82. $("#txtTitle").val("");
  83. $("#txtDescription").val("");
  84. $("#txtName").val("");
  85. }
  86. else {
  87. }
  88. },
  89. error: function(response) {
  90. alert(response.status + ' ' + response.statusText);
  91. }
  92. });
  93. });
  94. });
  95. </script>
  96. </head>
  97. <body>
  98. <form id="form1" runat="server">
  99. <table cellpadding="2" cellspacing="2" width="60%" align="center" style="border: Solid 5px Green;
  100. font-weight: bold; font-size: 12pt; background-color: Skyblue; color: Blue;">
  101. <tr>
  102. <td align="center" colspan="2" style="background-color: Yellow; font-family: Verdana;
  103. color: Red;">
  104. Write Your Daily Note
  105. </td>
  106. </tr>
  107. <tr>
  108. <td>
  109. Your Name #:
  110. </td>
  111. <td>
  112. <asp:TextBox runat="server" ID="txtName" Width="350px" />
  113. </td>
  114. </tr>
  115. <tr>
  116. <td>
  117. Note Title #:
  118. </td>
  119. <td>
  120. <asp:TextBox runat="server" ID="txtTitle" Width="350px" />
  121. </td>
  122. </tr>
  123. <tr>
  124. <td>
  125. Note Description #:
  126. </td>
  127. <td>
  128. <asp:TextBox runat="server" ID="txtDescription" Width="350px" Height="100px" TextMode="MultiLine" />
  129. </td>
  130. </tr>
  131. <tr>
  132. <td>
  133. </td>
  134. <td>
  135. <asp:Button ID="btnSubmit" runat="server" Text="Save Note" Width="120px" />
  136. </td>
  137. </tr>
  138. <tr>
  139. <td colspan="2">
  140. </td>
  141. </tr>
  142. </table>
  143. <div id="divRNoteBookData">
  144. </div>
  145. </form>
  146. </body>
  147. </html>
Now my aspx.cs code:
  1. using System;
  2. using System.Configuration;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.HtmlControls;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.WebControls.WebParts;
  11. using System.Xml.Linq;
  12. using System.Web.Services;
  13. using System.Data.SqlClient;
  14. using System.Collections.Generic;
  15. public partial class _Default : System.Web.UI.Page
  16. {
  17. protected void Page_Load(object sender, EventArgs e)
  18. {
  19. }
  20. [WebMethod]
  21. public static int saveData(string Title, string Description, string PostedBy)
  22. {
  23. try
  24. {
  25. SqlConnection con = new SqlConnection(@"DATA SOURCE=MyPC\SqlServer2k8;INTEGRATED SECURITY=TRUE;DATABASE=R-NoteBook");
  26. SqlDataAdapter da = new SqlDataAdapter("INSERT INTO MyNote(Title,Description, PostedBy) VALUES('" + Title + "', '" + Description + "', '" + PostedBy + "')", con);
  27. DataSet ds = new DataSet();
  28. da.Fill(ds);
  29. return 1;
  30. }
  31. catch
  32. {
  33. return -1;
  34. }
  35. }
  36. [WebMethod]
  37. public static RNoteBook[] getData()
  38. {
  39. RNoteBookCollection RNBC = new RNoteBookCollection();
  40. try
  41. {
  42. SqlConnection con = new SqlConnection(@"DATA SOURCE=MyPC\SqlServer2k8;INTEGRATED SECURITY=TRUE;DATABASE=R-NoteBook");
  43. if (con.State == ConnectionState.Closed)
  44. {
  45. con.Open();
  46. }
  47. SqlDataReader dr;
  48. SqlCommand cmd;
  49. string FetchData = "Select * From MyNote ORDER BY Posted_Date DESC";
  50. cmd = new SqlCommand(FetchData, con);
  51. dr = cmd.ExecuteReader();
  52. if (dr.Read())
  53. {
  54. while (dr.Read())
  55. {
  56. RNoteBook NB = new RNoteBook();
  57. NB.NoteTitle = dr["Title"].ToString();
  58. NB.NoteDesc = dr["Description"].ToString();
  59. NB.PostedBy = dr["PostedBy"].ToString();
  60. NB.PostedDate = dr["Posted_Date"].ToString();
  61. RNBC.Add(NB);
  62. }
  63. }
  64. return RNBC.ToArray();
  65. }
  66. catch
  67. {
  68. return RNBC.ToArray();
  69. }
  70. }
  71. }
  72. public class RNoteBook
  73. {
  74. public string NoteTitle { get; set; }
  75. public string NoteDesc { get; set; }
  76. public string PostedBy { get; set; }
  77. public string PostedDate { get; set; }
  78. }
  79. public class RNoteBookCollection : List<RNoteBook>
  80. {
  81. public void Add(RNoteBook RNB)
  82. {
  83. base.Add(RNB);
  84. }
  85. }
The following is my DataTable design:

design view
Image 1.

I have copied the script of my database into the App_Data folder in the application.

app data
Image 2.

Now run the application. You can enter your note and click on the Save Note button.

Note
Image 3.

Note pade
Image 4.

Here in this project you can see that to save data and to fetch data I used a JSON request. I made 2 web methods on Defaulr.aspx.cs.