ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Insert two Decimal place value in Database using jQuery AJAX and C# in ASP.Net<p>Hey <a class="username" rel="Richa">Richa</a>,</p> <p>Please refer below sample.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;script type=&#34;text/javascript&#34; src=&#34;http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; function saveData() { $.ajax({ type: &#34;POST&#34;, url: &#34;Default.aspx/SaveTextboxValues&#34;, data: &#39;{txtValue: &#34;&#39; + $(&#34;#&lt;%=textboxId.ClientID%&gt;&#34;)[0].value + &#39;&#34; }&#39;, contentType: &#34;application/json; charset=utf-8&#34;, dataType: &#34;json&#34;, success: OnSuccess, failure: function (response) { alert(response.d); } }); } function OnSuccess(response) { alert(response.d); } &lt;/script&gt; &lt;div&gt; &lt;asp:TextBox runat=&#34;server&#34; ID=&#34;textboxId&#34; /&gt; &lt;asp:Button Text=&#34;Save&#34; runat=&#34;server&#34; OnClientClick=&#34;saveData();&#34; /&gt; &lt;/div&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Web.Services; using System.Web.Script.Services; using System.Data.SqlClient; using System.Configuration; </pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">[WebMethod] [ScriptMethod()] public static void SaveTextboxValues(float txtValue) { string constr = ConfigurationManager.ConnectionStrings[&#34;constr&#34;].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { using (SqlCommand cmd = new SqlCommand(&#34;INSERT INTO TestDecimalValues VALUES(@FloadValue)&#34;, con)) { if (Convert.ToDouble(txtValue).ToString().IndexOf(&#39;.&#39;) &gt; -1) { cmd.Parameters.AddWithValue(&#34;@FloadValue&#34;, Convert.ToDouble(txtValue).ToString().Substring(0, Convert.ToDouble(txtValue).ToString().IndexOf(&#39;.&#39;) + 3)); } else { cmd.Parameters.AddWithValue(&#34;@FloadValue&#34;, txtValue); } con.Open(); cmd.ExecuteNonQuery(); con.Close(); } } }</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/123231/Insert-two-Decimal-place-value-in-Database-using-jQuery-AJAX-and-C-in-ASPNet/https://www.aspforums.net:443/Threads/123231/Insert-two-Decimal-place-value-in-Database-using-jQuery-AJAX-and-C-in-ASPNet/Tue, 18 Dec 2018 01:46:59 GMT