Dialog with child control becomes null on hide.
I have a control as below
<SfDialog @ref="@UserDialogObj" Visible="false" AllowDragging="true" EnableResize="true" ShowCloseIcon="true" Width="960px" Height="480px">
<DialogTemplates>
<Header>
User Details
</Header>
<Content>
<Control_User @ref="@controlUserObj"></Control_User>
</Content>
</DialogTemplates>
</SfDialog>
If i load the page as above, the control
controlUserObj is null and cannot access any properties. If Visible=true , then
controlUserObj is accessible.
What's the best practice to show hide Dialog with a child control?
| <SfDialog @ref="DialogObj" Width="450px" ShowCloseIcon="true" Visible=false> <DialogEvents Opened="@DialogOpen"></DialogEvents> <DialogTemplates> <Header> <div>Dialog Header</div> </Header> <Content> <CustomComponent @ref="rteObj"></CustomComponent> </Content> </DialogTemplates> </SfDialog>@code { SfDialog DialogObj; SfRichTextEditor RteObj; CustomComponent rteObj; private void OpenDialog() { this.DialogObj.ShowAsync(); } private void DialogOpen() { rteObj.refreshUI(); } } |
It appears removing the @ in the @ref property helped :) thank you
<SfDialog @ref="UserDialogObj" Visible="false" AllowDragging="true" EnableResize="true" ShowCloseIcon="true" Width="960px" Height="480px">
<DialogTemplates>
<Header>
User Details
</Header>
<Content>
<Control_User @ref="controlUserObj"></Control_User>
</Content>
</DialogTemplates>
</SfDialog>
Hi Anthony,
- 3 Replies
- 2 Participants
- Marked answer
-
AN Anthony
- Feb 9, 2023 10:43 AM UTC
- Feb 13, 2023 04:47 AM UTC