Hello,
I just upgraded to the latest release of asp controls. I created a webdialogwindow in a user control with exposed properties to set them in the webdialogwindow, like width height and image url and so forth. I also created a public method "Show" that takes a messagetype enum and a message string so I can display different types of messages (error, info, warning, question, and confirm).
I placed the user control on aspx page and now every time I call it in the code behind I get an error "Object reference not set to an instance of an object."
Why am I getting this?
Is there a better way to do what I'm trying to do?
Hello marcgh ,
Can you please share code snippet regarding the User Control + WebDialogWindow issue?
An isolated sample reproducing the issue will be appreciated.
Regarding the issue with closing the WebDialogWindow , you can hide it on client in order to avoid the post back.
Please refer to the below code snippet regarding this:
<script type="text/javascript">
function closeWDW() {
var wdw = $find('<%= WebDialogWindow1.ClientID %>');
wdw.hide();
}
</script>
<ig:WebDialogWindow ID="WebDialogWindow1" runat="server" Height="300px"
Width="400px">
<ContentPane>
<Template>
<asp:Button ID="Button1" runat="server" Text="Close" OnClientClick="closeWDW(); return false;" />
</Template>
</ContentPane>
</ig:WebDialogWindow>
Hope hearing from you.
This is my user control code:
<script type="text/javascript"> function closeDialog() { var dialog = $find('<%= WebMessageDialog.ClientID %>'); if (dialog) { //dialog.set_windowState($IG.DialogWindowState.Hidden); dialog.hide(); } }</script><ig:WebDialogWindow runat="server" ID="WebMessageDialog" InitialLocation="Centered" Width="350px" Modal="true" WindowState="Hidden" Style="line-height: normal" Moveable="true"> <Header CaptionAlignment="Left" Font-Bold="true"> <CloseBox Visible="true" /> </Header> <ContentPane> <Template> <div style="padding: 10px;"> <table> <tr> <td style="vertical-align: top; padding: 5px;"> <asp:Image ID="ImageMessage" runat="server" ImageAlign="AbsMiddle" /> </td> <td style="font-family: Trebuchet MS, Verdana, Arial;"> <asp:Literal ID="LiteralMessage" runat="server" /> </td> </tr> </table> </div> <div style="background-color: #e1e1e1; padding: 5px; text-align: right;"> <input type="button" onclick="closeDialog()" class="button" value="Close" /> </div> </Template> </ContentPane></ig:WebDialogWindow>
I drop the user control on a page. In code behind, whenever I validate a statement if it's null, I try to display the error message. Something like this:
if (isnull){ // throws object ref is not set to an instance of an object PageMessage.Show(WebMessageType.Error, "Value is null.");}
The WebMessage Type is an enum that changes the Image of the message whether it's error, info, success, warning or a question.
Thank you for your help,
OK, the issue was that my user control was outside the update panel, once i moved it inside it, it worked and the dialog message showed.
I am glad that you have found a solution.
Thank you for sharing with the comunity.