【问题标题】:Find runtime loaded user control(ascx) object in the page(aspx)在页面(aspx)中查找运行时加载的用户控件(ascx)对象
【发布时间】:2012-08-16 20:17:08
【问题描述】:

我正在使用 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;

        }

aspx 页面

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

}

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

【问题讨论】:

    标签: jquery asp.net user-controls ascx


    【解决方案1】:

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

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

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

    <%@ Reference Control="~/user_controls/yourUserControlType.ascx"%>
    

    【讨论】:

      【解决方案2】:
      猜你喜欢
      • 1970-01-01
      • 2012-01-11
      • 2014-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多