简体   繁体   English

使用ajax加载用户控件

[英]To Load user control using ajax

In the below Code i have a user control i want to bind user control using ajax web method.I tried no idea to solve it .Pls help me to solve the issue. 在下面的代码中,我有一个用户控件,我想使用Ajax Web方法绑定用户控件。我没有办法解决它。请帮我解决问题。

Sample.aspx Sample.aspx

<test:school ID="usr" runat="server"/>


[WebMethod]
public static string LoadUserControl()
{
 TestSchool.SchoolBusinessLyr.SchoolBizClient SelectDistrict = new TestSchool.SchoolBusinessLyr.SchoolBizClient();
            DataSet ds = new DataSet();
ds = SelectDistrict.SelectDistrict();
usr.field=ds.Tables[0];
usr.DataBind();
}

You can't bind an existing user control using AJAX; 您不能使用AJAX绑定现有的用户控件。 you can return data to the client, which JavaScript can then update the UI where the user control is (programmatically), or you can use an UpdatePanel to update the UI from the server... you can also return the HTML of the user control, but that is a little more complicated... 您可以将数据返回给客户端,然后JavaScript可以通过编程来更新用户控件所在的UI,或者您可以使用UpdatePanel从服务器上更新UI ...还可以返回用户控件的HTML ,但这有点复杂...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM