Hi There,
I would like to declare a WebDialogWindow and open it in my code behind page to show a message when something is wrong. How would I do that.
Thanks for the help.
Best Regards,
Steve.
Hello Steve,
Please refer to this topic for more information on how to open a WebDialogWindow from the code-behind. If you want to declare it also in the code-behind instead of using the designer, you can use the same topic to get the important property names (they are hyperlinked).
To show the dialog window from the code behind:
this.WebDialogWindow1.WindowState = Infragistics.Web.UI.LayoutControls.DialogWindowState.Normal;
Elizabeth AlbertLocalization Engineer
Hi Elizabeth,
Thanks for your reply but that did not work. The webDialog did not show.My page has various divs and I was wondering whether the webdialog has to be declared in a certain place so that the call from codebehind can show it.
I am trying to show the webdialog when a selectedindexchange on a dropdown is triggered. I have debugged and stepped through the code and the dialogwindowstate.normal is definately being called.
Thank you for the clarification regarding the scenario.
By default the SelectionChanged event is asynchronous.
You should set the AutoPostBackFlags regarding this event to be turned on , because full postback is needed in order to change the state of the WebDialogWindow.
Please refer to the sample code snippet below:
<ig:WebDropDown ID="WebDropDown1" runat="server" Width="200px" OnSelectionChanged="WebDropDown1_SelectionChanged">
<AutoPostBackFlags SelectionChanged="On" />
<Items>
<ig:DropDownItem Selected="False" Text="RightOption" Value="">
</ig:DropDownItem>
<ig:DropDownItem Selected="False" Text="WrongOption" Value="">
</Items>
</ig:WebDropDown>
<ig:WebDialogWindow ID="WebDialogWindow1" runat="server" Height="300px" Width="400px"
WindowState="Hidden">
</ig:WebDialogWindow>
protected void WebDropDown1_SelectionChanged(object sender, Infragistics.Web.UI.ListControls.DropDownSelectionChangedEventArgs e)
{
int newSelectedItem = (int) e.NewSelection;
if (WebDropDown1.Items[newSelectedItem].Text.Equals("WrongOption")) {
WebDialogWindow1.WindowState = Infragistics.Web.UI.LayoutControls.DialogWindowState.Normal;
}
Let us know if you need further assistance regarding this.
I tried to make a sample for this, but I was unable to get the dropdown events to fire. I got it working with a button, but that does a post back.
In general, there are 3 settings that could affect the visibility of the dialog: Enabled, Visible, and WindowState. In my sample with the button, I kept Enabled set to true through the designer and never changed it. I set Visible to False in the designer, but set it to True in the button click event. I kept the WindowState set to Normal in the dialog, and changed it to Normal in the event, just in case the dialog had previously been shown and closed. The result was that the dialog window was displayed when I clicked on the button (after the postback).
This might be solved with client-side programming. I tried but I couldn't get the dialog variable to be anything other than null. Here is the topic I referenced, and here is a general topic about client side event handling. I am unfamiliar with it (I do localization!), so please give it a try.
<script type="text/javascript"> function WebDropDown1_SelectionChanged(sender, dropDownArgs) { var dialog = $find('<%= WebDialogWindow1.ClientID %>'); dialog.show(); }</script>
<ig:WebDialogWindow ID="WebDialogWindow1" runat="server" Height="300px" Width="400px" Visible="False"> </ig:WebDialogWindow> <ig:WebScriptManager ID="WebScriptManager1" runat="server"> </ig:WebScriptManager> <ig:WebDropDown ID="WebDropDown1" runat="server" Width="200px"> <Items> <ig:DropDownItem Selected="False" Text="Item #1" Value=""> </ig:DropDownItem> <ig:DropDownItem Selected="False" Text="Item #2" Value=""> </ig:DropDownItem> <ig:DropDownItem Selected="False" Text="Item #3" Value=""> </ig:DropDownItem> <ig:DropDownItem Selected="False" Text="Item #4" Value=""> </ig:DropDownItem> </Items> <ClientEvents SelectionChanged="WebDropDown1_SelectionChanged" /> </ig:WebDropDown>
I hope this is helpful.