0

我正在使用 jquery-ajax 将动态用户控件(ascx)加载到页面(aspx)。运行时,我想要一个已加载到 Page 中的用户控件实例。我能怎么做?谢谢

       function funDersinSubeleriniGoster(programDersGrubDersId) {
            $.blockUI();
            var ControlName = "OgrenciUserControls/KayitYenileme/DersSubeleriControl.ascx";
            $.ajax({
                type: "POST",
                url: "KayitYenileme.aspx/DersinSubeleriniYukle",
                data: "{controlName:'" + ControlName + "',programDersGrubDersId:'" + programDersGrubDersId + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                    $.unblockUI();
                    //$('#dialogDersKayitPopup').html(response.d).dialog({ resizable: false, height: 600, width: 800, modal: true });
                },
                failure: function (msg) {
                    $.unblockUI();
                    //$('#dialogDersKayitPopup').html(msg).dialog({ resizable: false, height: 600, width: 800, modal: true });
                }
            });

            return false;

        }

页面

[WebMethod]
public static void DersinSubeleriniYukle(string controlName, int programDersGrubDersId)
{

}

private void UserControlsFind()
{
    //I want to have user controls instance.
}
4

2 回答 2

0

答案是:通过 jQuery 加载 ascx

还可以在这里查看:http: //zemlyaniy.wordpress.com/2011/07/11/render-ascx-control-to-pure-html-and-load-using-jquery/

于 2014-02-06T11:00:06.010 回答
0

如果您传递对象名称(您的 DersinSubeleriniYukle sub 中的 controlName),您可以从服务器端找到该控件:

dim myControl as yourUserControlType 
myControl = me.findControl(controlName)

您可能需要在 ascx 页面中添加参考,如下所示:

<%@ Reference Control="~/user_controls/yourUserControlType.ascx"%>
于 2013-03-04T20:16:34.120 回答