Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用ajax在aspx中绑定Usercontrol_C#_Asp.net_Ajax - Fatal编程技术网

C# 使用ajax在aspx中绑定Usercontrol

C# 使用ajax在aspx中绑定Usercontrol,c#,asp.net,ajax,C#,Asp.net,Ajax,在下面的代码中,我有一个usercontrol.ascx,我有一个textbox和dropdown,我想用db检查字段是textbox还是dropdown,我想用ajax显示在sample.aspx中。请帮我做这个 Control.ascx <table width="100%"> <tr> <td> <input type="text" id="btnField" value="Val" /> <

在下面的代码中,我有一个usercontrol.ascx,我有一个textbox和dropdown,我想用db检查字段是textbox还是dropdown,我想用ajax显示在sample.aspx中。请帮我做这个

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;     
         }

函数LoadUserControl(){
$.ajax({
类型:“POST”,
url:“Sample.aspx/LoadControls”,
数据:“,
contentType:“应用程序/json;字符集=utf-8”,
数据类型:“json”,
成功:功能(r){
var data=$.parseJSON(r.d);
警报(r.d);
}
});        
}
//将返回文本框或下拉列表
[System.Web.Services.WebMethod]
公共静态字符串加载控件()
{
字符串测试=“2”;
客户端控件=新客户端();
数据集dsField=Controls.GetFieldData(Int32.Parse(Test));
字符串sReturn=JsonConvert.SerializeObject(dsField.Tables[0]).ToString();
回报率;
}

你被困在哪里?@Amit Kumar Ghosh我不知道如何在aspx页面绑定usercontrol,因为我是asp.netse新手。请看这个@Amit Kumar Ghosh我试过了,但没有work@AmitKumar Ghosh谢谢它工作了你被困在哪里?@Amit Kumar Ghosh我不知道如何在aspx页面绑定用户控件,因为我是asp.NET新手。请看这个@Amit Kumar Ghosh我试过了没有work@Amit库马尔·戈什,谢谢你,它很管用