webform将一个usercontrol作为模态框在page上弹出

弹窗

public static void RegisterJQueryDialogScript(Page page, string dialogDivId, string title, int width, int height, bool autoOpen, string openTriggerClientId)
        {
            if (string.IsNullOrEmpty(title))
                title = "Form";

            var heightStr = string.Empty;
            var witdthStr = string.Empty;
            if (height > 0)
                heightStr = "height: " + height.ToString() + ",";
            if (width > 0)
                witdthStr = " " + width.ToString() + ",";

            string script = @"
$(function ()
{
    $('#dialog:ui-dialog').dialog('destroy');
    $('#" + dialogDivId + @"').dialog(
        {
            title: '" + title + @"',
            autoOpen:" + autoOpen.ToString().ToLower() + "," +
            heightStr +
            witdthStr + @"
            closeText: 'No',
            modal: true,
            resizable: false
        }
    ).parent().appendTo('form');
}
);
";
            string scriptKey = "Open" + dialogDivId;
            if (autoOpen)
                ScriptManager.RegisterStartupScript(page, page.GetType(), scriptKey, script, true);
            else
            {
                ScriptManager.RegisterClientScriptBlock(page, page.GetType(), scriptKey, script, true);

                var scriptTrigger = @"$('#" + openTriggerClientId + @"')
                        .click(function () {
                            $('#" + dialogDivId + @"').dialog('open');
                            return false;
                        });";
                scriptKey += "Trigger";
                ScriptManager.RegisterStartupScript(page, page.GetType(), scriptKey, scriptTrigger, true);
            }
        }

Open a user control in a pop up

原文地址:https://www.cnblogs.com/chucklu/p/10874335.html