c# - To bind Usercontrol in aspx using ajax -
in below code have usercontrol control.ascx have textbox , dropdown , want check db whether field textbox or dropdown , want display in sample.aspx using ajax. pls me this.
control.ascx
<table width="100%"> <tr> <td> <input type="text" id="btnfield" value="val" /> </td> <td> <select id="cbb" style="width:75%"></select> </td> </tr> </table>
sample.aspx
<table> <tr> <td> <uc1:ucreport id="ucreport" runat="server" /> </td> </tr> </table> function loadusercontrol() { $.ajax({ type: "post", url: "sample.aspx/loadcontrols", data: "", contenttype: "application/json; charset=utf-8", datatype: "json", success: function (r) { var data = $.parsejson(r.d); alert(r.d); } }); } //will return textbox or dropdown [system.web.services.webmethod] public static string loadcontrols() { string test= "2"; client controls = new client(); dataset dsfield = controls.getfielddata(int32.parse(test)); string sreturn = jsonconvert.serializeobject(dsfield.tables[0]).tostring(); return sreturn; }
Comments
Post a Comment