How to open Uniselector modal dialog on a button click?

Mani SJ asked on February 5, 2020 04:40

I am using kentico 12. I have a unigrid(object list).Upon cliking on edit on a row,I will show a General tab(1st vertical tab) which has UIForm then in the next vertical tab I have a button. When I click this button I want to open a uniselector modal dialog showing a object listing based on the edited object Id. From this uniselector list, I will select what's needed and click save. So finally only selected data will be shown in the second vertical tab.

I have below code called during override OnInit()

    var dialogUrl = ApplicationUrlHelper.GetElementDialogUrl("ModuleName", "ElementName");
    dialogUrl = URLHelper.GetAbsoluteUrl(dialogUrl);
    var dialogScript = ScriptHelper.GetModalDialogScript(dialogUrl , "Detail", "500", "500");

    var page = (CMSUIPage)Control.Page;
    var buttonHeaderAction = new HeaderAction()
    {
        Text = ResHelper.GetString(Text),
        ButtonStyle = ButtonStyle,
        OpenInDialog = true,
        DialogHeight = "500",
        DialogWidth = "500",
        OnClientClick = dialogScript,
        CommandName = Text.Replace(" ", string.Empty)
    };
    page.AddHeaderAction(buttonHeaderAction);

I am getting error in browser console as modalDialog('dialogUrl value inside') is not defined upon button click. Kindly help

I referred this link( https://devnet.kentico.com/articles/module-development-ui-extenders ).

Recent Answers


Mani SJ answered on February 6, 2020 03:49

ScriptHelper.RegisterDialogScript(Control.Page); needs to be wriiten before GetModalDialogScript()

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.