Lifecycle C1Dialog. MasterPage, UserControl ascx using C1Dialog 2025v2 399

Posted by: enrique.pv-ext on 12 June 2026, 3:40 am EST

  • Posted 12 June 2026, 3:40 am EST

    Hi,

    Migrate from 2010v1 to 2025v2 399 in ASP.NET WebForms NET Framework 4.8.1.

    Migrate C1Window to C1Dialog.

    Using C1Dialog from C1.Web.Wijmo.Controls.48.dll

    UserControl ascx using C1Dialog

    <cc2:C1Dialog ID="C1Window1" runat="server" Height="250px" Width="500px"
        Title="Notification Dialog"
        Resizable="False"
        ShowOnLoad="False" 
        >
        <Content>
                                <asp:Label ID="lblMessage" runat="server" CssClass="minititle"></asp:Label>   

    NOw, I get error: lblMessage is null in any Postback in my pages aspx.

    My aspx use a MasterPage.

    MasterPage use a custom UserControl ascx.

    My custom UserControl ascx use a C1Dialog control (name C1Window1 , was legacy).

    C1Window vs C1Dialog: lifecycle changed ?

    C1Dialog In Wijmo 2025v2, C1Dialog instantiates its template differently (during CreateChildControls()/rendering phase),

    which happens after the PostBack event handlers fire. This is why C1Window1.Title works fine (it’s a direct child of the UserControl), but lblMessage—inside the C1Dialog template—is still null when accessed by show().

    ViewState solution ??

    The solution is to use ViewState as the authoritative store for Message and synchronize it to the control on OnPreRender, where all controls are guaranteed.

    Key to the problem: C1Window1.Title works because C1Window1 is a direct child of the UserControl.

    lblMessage, btnAccept, etc., reside within the template of C1Dialog, which Wijmo 2025v2 instantiates deferred. The ViewState acts as a bridge between the event handler (where the control is still null) and the PreRender (where it is already available).

    any suggestions about real lifecycle C1Dialog , and about Content template rendering-instantiates ?

  • Posted 12 June 2026, 7:33 am EST

    Hello Enrique,

    Could you please share a small sample application that reproduces the issue?

    From the information provided, it is difficult to determine whether this is due to a lifecycle change in C1Dialog, the way the UserControl is being loaded, or another application-specific factor.

    In particular, it would be helpful to review:

    • The MasterPage implementation
    • The UserControl containing the C1Dialog
    • The code where lblMessage is accessed during postback
    • The exact event in which the control is found to be null

    Once we can reproduce the behavior, we will investigate further and clarify the expected lifecycle of C1Dialog and its content template.

    Regards,

    Uttkarsh.

  • Posted 30 June 2026, 11:11 am EST

    UserControl MessageDialog.ascx:

    <cc2:C1Dialog ID="C1Window1" runat="server" Height="250px" Width="500px"
        Title="Notification Dialog"
        Resizable="False"
        ShowOnLoad="False" 
        >
    
    <CaptionButtons>
         <Close Visible="false" />
         <Pin Visible="false" />
         <Refresh Visible="false" />
         <Toggle Visible="false" />
    	    <Minimize Visible="false" />
      <Maximize Visible="false" />
     </CaptionButtons>
    
        <Content>
    ...
    <asp:Label ID="lblMessage" runat="server" CssClass="minititle"></asp:Label>   
    ...

    ascx.cs

            public void Show(MessageDialogOptions options)
            {
                show(options);
            }
      public string Message
      {
          set { lblMessage.Text = value; }
          get { return lblMessage.Text; }
      }
      private void show(MessageDialogOptions options)
      {
          if (options.Title != null) Title = options.Title;
          if (options.Message != null) Message = options.Message;
          if (options.Icon != null) Icon = options.Icon.Value;
          if (options.DialogButtons != null) DialogButtons = options.DialogButtons.Value;
          if (options.AcceptButtonText != null) AcceptButtonText = options.AcceptButtonText;
          if (options.CancelButtonText != null) CancelButtonText = options.CancelButtonText;
          if (options.OnAcceptButtonClientClick != null) OnAcceptButtonClientClick = options.OnAcceptButtonClientClick;
          if (options.OnCancelButtonClientClick != null) OnCancelButtonClientClick = options.OnCancelButtonClientClick;
    
          if (!string.IsNullOrEmpty(options.Width)) Width = new Unit(options.Width);
          if (!string.IsNullOrEmpty(options.Height)) Height = new Unit(options.Height);
    
          if (!IsPostBack)
          {
              //C1Window1.ShowModalWindowOnLoad = true // NO EXISTE ShowModalWindowOnLoad en 2025v2 399
              C1Window1.ShowOnLoad = true;
          }
          else
          {
              string script = string.Format(@"window.{0}.Show({{ title:'{1}',message:'{2}',icon:{3},buttons:{4}, width:'{5}', height:'{6}' }});", ClientID, Title, System.Web.HttpUtility.JavaScriptStringEncode(Message), (int)Icon, (int)DialogButtons, Width.ToString(), Height.ToString());
              clientScripts.Add(script);
          }
      }
    

    Master

    <%@ Register Src="~/Controls/MessageDialogNEW.ascx" TagName="MessageDialog" TagPrefix="uc1" %>
    ...
    <body id="Body" runat="server">
    	<form id="form1" runat="server" submitdisabledcontrols="True">
    
    		<asp:ToolkitScriptManager ... 		</asp:ToolkitScriptManager>
    		<asp:ScriptManagerProxy ...		</asp:ScriptManagerProxy>
    
    ...				<asp:UpdatePanel ID="UpdatePanelClock" runat="server" UpdateMode="Conditional">...
    				</asp:UpdatePanel>
    ...
    	<cc1:C1Menu ID="C1Menu1" runat="server" Height="23px" Width="295px" OnLoad="C1Menu1_Load"...				</cc1:C1Menu>
    
    		<asp:Panel ID="DivContentPlaceHolder1" runat="server" class="contenido"
    			DefaultButton="btnGridFilterProxy">
    
    			<asp:Button ID="btnGridFilterProxy" runat="server" Style="display: none"
    				OnClientClick="return false;" UseSubmitBehavior="false" />
    
    			<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
    			</asp:ContentPlaceHolder>
    		</asp:Panel>
    
    ...
    				<asp:ContentPlaceHolder ID="ContentButtons" runat="server">
    				</asp:ContentPlaceHolder>
    
    		<uc1:MessageDialog ID="MessageDialog1" runat="server" />
    	</form>
    </body>
    </html>

    Master.cs

      private void showMessageDialog(MessageDialogOptions options)
      {
          MessageDialog1.Show(options);
      }
      public void ShowMessageDialog(MessageDialogOptions options)
      {
          showMessageDialog(options);
      }

    event throw error in another ascx (base class BaseUserControl)

       protected override void OnInit(EventArgs e)
       {
    ...
       }
       catch (Exception ex)
       {
           Logger.Error(ex);
           ShowMessageDialog(new MessageDialogOptions
           {
               Title = GetTranslation(20),
               Message = GetTranslation(42),
               Icon = DialogIcon.Error,
               DialogButtons = DialogButtons.OkOnly,
           });
       }

    Base Class: BaseUserControl

      public void ShowMessageDialog(MessageDialogOptions options)
      {
          if (CurrentPage is ContentBasePage)
          {
              (CurrentPage as ContentBasePage).CurrentMaster.ShowMessageDialog(options);
          }
    	  

    thanks a lot , I hope you can reproduce the behavior

  • Posted 1 July 2026, 10:12 am EST

    Hello Enrique,

    We’re looking into the details you have provided and will update you once we have more information to share.

    Regards,

    Uttkarsh.

  • Posted 3 July 2026, 5:01 am EST

    Hello Enrique,

    After further investigating the issue and understanding your use case, we recommend displaying the C1Dialog in OnPreRender() instead of OnInit().

    Currently, C1Dialog.Show() is being called inside the try-catch block in OnInit(), which executes before the dialog has been fully initialized. As a result, the dialog cannot be displayed correctly at that stage.

    The recommended approach is to catch and store the exception during OnInit(), and then display the C1Dialog with the exception details from OnPreRender(), after the control has been initialized.

    Please refer to the attached sample for implementation: Dialog_Sample.zip

    If this does not resolve the issue, we would appreciate it if you could provide a stripped-down sample that reproduces the behavior. With only code snippets, it may not be possible for us to investigate the issue thoroughly. You can also incorporate your implementation into the sample we’ve provided and share the steps required to reproduce the problem.

    Regards,

    Uttkarsh.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels