Sunday 15 February 2015

c# - how to insert value to database that is fetched by jquery using json autocomplete in asp.net -



c# - how to insert value to database that is fetched by jquery using json autocomplete in asp.net -

to whom may respond to,

we trying insert info oracle dbms, fetched json calling asp.net webservices. here,aspx page modified code stackoverflow answer. have utilize json 1 time again send values codebehind ? if so, how? http://www.codingfusion.com/post/jquery-json-add-edit-update-delete-in-asp-net sample scripts

thank concern

<%@ page title="home page" language="c#" masterpagefile="~/site.master" autoeventwireup="true" codebehind="default.aspx.cs" inherits="test7._default" %> <asp:content id="headercontent" runat="server" contentplaceholderid="headcontent"> </asp:content> <asp:content id="bodycontent" runat="server" contentplaceholderid="maincontent"> <asp:scriptmanagerproxy id="scriptmanagerproxy1" runat="server"> <scripts> <asp:scriptreference path="scripts/jquery-1.11.1.min.js" /> <asp:scriptreference path="scripts/jquery-ui.min.js" /> </scripts> </asp:scriptmanagerproxy> <div id="outer" style="width: 100%; background-color: #737ca1"> <div id="headdiv" style="width: 90%; background-color: #737ca1"> <script type="text/javascript" id="butcelist"> $(function () { $("#txtbutce").autocomplete({ source: function (request, response) { var param = { prefixtext: $('#txtbutce').val() }; $.ajax({ url: "default.aspx/getbutce", data: json.stringify(param), datatype: "json", type: "post", contenttype: "application/json; charset=utf-8", datafilter: function (data) { homecoming data; }, success: function (data) { response($.map(data.d, function (item) { homecoming { value: item } })) }, error: function (xmlhttprequest, textstatus, errorthrown) { alert(textstatus); } }); }, minlength: 2//minlength 2, means when ever user come in 2 character in textbox autocomplete method fire , source data. }); }); </script> <script type="text/javascript" id="tiplist"> $(function () { $("#txttip").autocomplete({ source: function (request, response) { var param = { prefixtext: $('#txttip').val() }; $.ajax({ url: "default.aspx/gettip", data: json.stringify(param), datatype: "json", type: "post", contenttype: "application/json; charset=utf-8", datafilter: function (data) { homecoming data; }, success: function (data) { response($.map(data.d, function (item) { homecoming { value: item } })) }, error: function (xmlhttprequest, textstatus, errorthrown) { alert(textstatus); } }); }, minlength: 2//minlength 2, means when ever user come in 2 character in textbox autocomplete method fire , source data. }); }); </script> <script type="text/javascript"> function openmodalform() { window.showmodaldialog('details.aspx', '', 'status:1; resizable:1; dialogwidth:900px; dialogheight:500px; dialogtop=50px; dialogleft:100px') } </script> <script type="text/javascript"> function savedata() { //==== phone call validatedata() method perform validation. method homecoming 0 //==== if validation pass else returns number of validations fails. //var errcount = validatedata(); //==== if validation pass save data. var txtbutce = $("#txtbutce").val(); var txttip = $("#txttip").val(); $.ajax({ type: "post", url: "default.aspx/savedata", data: json.stringify({butce:txtbutce,tip:txttip}), contenttype: "application/json; charset=utf-8", datatype: "jsondata", async: "true", success: function (response) { $(".errmsg ul").remove(); var myobject = eval('(' + response.d + ')'); if (myobject > 0) { $(".errmsg").append("<ul><li>data kaydedildi</li></ul>"); } else { $(".errmsg").append("<ul><li>kayıt işleminde hata olustu, tekrar deneyiniz.</li></ul>"); } $(".errmsg").show("slow"); clear(); }, error: function (response) { alert(response.status + ' ' + response.statustext); } }); } </script> <div class="ui-widget"> <label for="txtbutce" >bütçe kodu/lokasyon: </label> <input id="txtbutce"> <br /> <label for="txttip">tip/alttip: </label> <input id="txttip" /> </div> <asp:label id="lbldateinfo" runat="server" style="color: white;" /><br /> <asp:button id="btncalshow" runat="server" text="tarih seçiniz" /> <asp:button id="btnshow" runat="server" text="show modal popup" /> </div> <br /> <asp:button id="btnpenaltycalculate" text="hesapla" runat="server" style="margin-left: 0px; margin-top: 5px; margin-bottom: 5px;" /> <asp:button id="btnpenaltysubmit" text="kaydet" runat="server" style="margin-left: 5px; margin-top: 5px; margin-bottom: 5px;" /> <%-- %> <asp:button id="btnrefresh" runat="server" text="haftayı yeniden yükle" style="margin-left:60px;margin-top:5px;margin-bottom:5px;" /> --%> </div> </asp:content>

you need ajax post webmethod (or asp.net postback) send info server can update database.

c# jquery asp.net json database

No comments:

Post a Comment