ASPxPopupControl clear all layout group - asp.net

I want to clear all contents in all LayoutGroups.
So I use
<dx:ASPxPopupControl ID="AspxPopUPDeneme" runat="server" ClientInstanceName="AspxPopUPDeneme" ClientSideEvents-Closing="function(s,e){ASPxClientEdit.ClearEditorsInContainerById('form_clear');}">
<ContentCollection>
<dx:PopupControlContentControl>
<div id="form_clear">
<dx:ASPxFormLayout ID="ASPxFormLayoutDeneme" runat="server" ClientInstanceName="ASPxFormLayoutDeneme">
<Items>
<dx:TabbedLayoutGroup>
<Items>
<dx:LayoutGroup>....</dx:LayoutGroup>
<dx:LayoutGroup>....</dx:LayoutGroup>
</Items>
</dx:TabbedLayoutGroup>
</Items>
</dx:ASPxFormLayout>
</div>
But this method only clear active LayoutGroup when I closing the PopUp.
My problem as shown in this image
How can I solve this problem?

By default, ClearEditorsInContainerById clears all visible editors (i.e. in active tab) that belongs to a container group given by certain containerId. To include invisible editors on other tab, use 3-argument version of ClearEditorsInContainerById as shown below:
function clearAllOnClose(s, e)
{
ASPxClientEdit.ClearEditorsInContainerById('form_clear', null, true);
}
<dx:ASPxPopupControl ID="AspxPopUPDeneme" runat="server" ClientInstanceName="AspxPopUPDeneme"
ClientSideEvents-Closing="clearAllOnClose">
<ContentCollection>
<dx:PopupControlContentControl runat="server">
<div id="form_clear">
<dx:ASPxFormLayout ID="ASPxFormLayoutDeneme" runat="server" ClientInstanceName="ASPxFormLayoutDeneme">
<Items>
<dx:TabbedLayoutGroup>
<Items>
<dx:LayoutGroup>....</dx:LayoutGroup>
<dx:LayoutGroup>....</dx:LayoutGroup>
</Items>
</dx:TabbedLayoutGroup>
</Items>
</dx:ASPxFormLayout>
</div>
</dx:PopupControlContentControl>
</ContentCollection>
</dx:ASPxPopupControl>
Setting true in third argument means that null values are assigned to all controls under form_clear div container, regardless of their visibility status.
Note from documentation:
If the validationGroup parameter is set to null, the method clears
all/visible (under the clearInvisibleEditors parameter value) editors
located within the specified container.
Reference:
DevExpress Documentation: ClearEditorsInContainerById

Related

asp.net how to change visibility of a menu item from load function in .cs

<div id = "menu2" style ="position:absolute;right:400px; margin-top: -55px;">
<asp:Menu ID="Menu2" runat="server" Height="16px" style="margin-left: 1125px"
Width="63px" Visible="False">
<Items>
<asp:MenuItem Text="Economics" Value="Economics" ImageUrl="~/images/dollar.png"></asp:MenuItem>
</Items>
</asp:Menu> </div>
The above code is located in .aspx page. In the load function in the .cs file , how can I change the visibility of this menu?
I can change the NavigationUrl via the following statement
Menu1.Items[0].NavigateUrl = AfeAttachment;
but I can't seem to adjust the visibility
Paste the following the code into the method you're using to change the menu's visibile attribute:
Menu2.Visible = true;

.NET 4.5: ASP Menu Item value displaying as a link?

In my code below the asp menu item value property is actually rendering as link text!
<asp:Menu ID="menuTop" runat="server" EnableViewState="true" Orientation="Horizontal" StaticSelectedStyle-CssClass="menuselected" SkipLinkText="">
<Items>
<asp:MenuItem NavigateUrl="~/Default.aspx" ImageUrl="~/images/Menu_Home.jpg" Value="Home" />
<asp:MenuItem NavigateUrl="~/Contact.aspx" ImageUrl="~/images/Menu_Contact.jpg" Value="Contact"/>
</Items>
</asp:Menu>
According to the MSDN reference located at http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.menuitem.value.aspx
The Value property is used to supplement the Text property by storing
any additional data associated with the menu item. This value is not
displayed in the control and is commonly used to store data for
handling postback events.
I need it to store values, why is it displaying as link text?
Try this code.
<asp:Menu ID="menuTop" runat="server" EnableViewState="true" Orientation="Horizontal" StaticSelectedStyle-CssClass="menuselected" SkipLinkText="">
<Items>
<asp:MenuItem NavigateUrl="~/Default.aspx" ImageUrl="~/images/Menu_Home.jpg" Value="Home" Text="" />
<asp:MenuItem NavigateUrl="~/Contact.aspx" ImageUrl="~/images/Menu_Contact.jpg" Value="Contact" Text=""/>
</Items>
</asp:Menu>
Nevermind, I figured it out. Looks like you need to set the Text value to "" and that prevents the value from displaying as text.

How to use combobox in devexpress aspxgridview

I am displaying my data in a devexpress gridview. One of the column is state value. When the grid is edited, I have to show the state in a combobox, so that the user could change the state by choosing a different state. Currently it is displayed in a textbox, since it is the default. Essentially when the user clicks the edit button, a combobox should be displayed as part of the edit controls, and the combobox should be populated with all possible states in the codebehind and the selected value should be the initial value on the grid. It is very easy do it in MS gridview. But I couldn't see any sample code for how to do it in the devexpress gridview.
Thanks
Use GridViewDataComboBoxColumn. Declare datasource and attach it to combo box column or populate it in code behind. This example contains both variants.
You can also take a look at DevExpress grid editing demos.
<dx:GridViewDataTextColumn FieldName="FieldName" VisibleIndex="4">
<EditItemTemplate>
<dx:ASPxComboBox ID="ASPxComboBox1" runat="server" DataSourceID="newDataSource" >
</dx:ASPxComboBox>
</EditItemTemplate>
</dx:GridViewDataTextColumn>
You'll need to set the datasource so you'll get the list of values
If you don't have a data source and want to include the combo box items in your code, here's another way to create the column:
<dx:GridViewDataComboBoxColumn FieldName="QAAproval" VisibleIndex="11" Width="30px">
<PropertiesComboBox>`enter code here`
<Items>
<dx:ListEditItem Text="GENERIC" Value="GENERIC" />
<dx:ListEditItem Text="FAIR" Value="FAIR" />
<dx:ListEditItem Text="VSE" Value="VSE" />
<dx:ListEditItem Text="ECAV" Value="ECAV" />
<dx:ListEditItem Text="FMMDS" Value="FMMDS" />
<dx:ListEditItem Text="CLEAR" Value="CLEAR" />
</Items>
</PropertiesComboBox>
<CellStyle Font-Size="XX-Small">
</CellStyle>
</dx:GridViewDataComboBoxColumn>
Edit the GridView Template, and in the EditTemplate of the field, add the dropdownbox. It might come to look like this
<dx:GridViewDataTextColumn Caption="Field Name"
FieldName="FieldName" VisibleIndex="3">
<EditItemTemplate>
<cc1:DropDownList ID="DropDownList1" runat="server">
</cc1:DropDownList>
</EditItemTemplate>
</dx:GridViewDataTextColumn>
So when you edit that row, it will show the DDL
I have used the following code to have combo box in the aspxgridview.
I hope this example helps :
<dx:GridViewDataComboBoxColumn FieldName="DatabaseFieldName" Settings-FilterMode="DisplayText"
Width="3%" VisibleIndex="3" Visible="True" Caption="Priority" Settings-AutoFilterCondition="Contains"
HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center"
CellStyle-VerticalAlign="Top">
<PropertiesComboBox ValueType="System.String" DataSourceID="objDataSourceID"
Width="200px" Height="25px" TextField="TextFieldName" ValueField="ValueFieldName"
IncrementalFilteringMode="StartsWith">
</PropertiesComboBox>
</dx:GridViewDataComboBoxColumn>

ASP.NET: Highlight menu item of current page

I've been trying to find an easy way of highlighting the current selected menu item of an asp.net menu (so the user knows which page they are on), but no matter what I have tried I can't get it to work. In my markup I have:
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal" StaticSelectedStyle-ForeColor="#99CCFF" DynamicSelectedStyle-ForeColor="#99CCFF">
<Items>
<asp:MenuItem NavigateUrl="~/Default.aspx" Text="Operations"/>
<asp:MenuItem NavigateUrl="~/Analysis.aspx" Text="Analysis"/>
<asp:MenuItem NavigateUrl="~/Dashboard.aspx" Text="Dashboard"/>
<asp:MenuItem NavigateUrl="~/Flashboard.aspx" Text="Flashboard"/>
<asp:MenuItem NavigateUrl="~/Spacequest.aspx" Text="SQ OBP"/>
</Items>
</asp:Menu>
And in the server side Page_Load function:
((Menu)Master.FindControl("NavigationMenu")).Items[0].Selected = true;
But this does not work. I tried using a sitemap (even though a sitemap is not what I want to use) and that hasn't worked either. Any ideas?
There's a StaticSelectedStyle property that you can use inside your menu.
<asp:menu [...]>
<staticselectedstyle backcolor="LightBlue"
borderstyle="Solid"
bordercolor="Black"
borderwidth="1"/>
[...]
</asp:menu>
See here for more info.
Also, if there's a class applied to the selected item (which i'm not sure if there is but it would be handy) you can simply hook into that with your CSS. This would be a much nicer way than using the StaticSelectedStyle property.
UPDATE
It's worth noting also that your use of IncludeStyleBlock="false" will stop your menu from generating the CSS necessary to control the selected item.
With the style block turned off, you have to provide your own styles and the auto-generated styles of the menu will not be used.
From MSDN:
If you set this property to false, you cannot set style properties.
For example, you cannot add a DynamicHoverStyle-ForeColor attribute in
markup or set the DynamicHoverStyle.ForeColor property in code.
Source: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.menu.includestyleblock.aspx
I think you'll have to loop through the menu items and see if the current page URL contains the NavigateUrl of the menu item.
foreach (MenuItem item in mn.Items)
{
if (Request.Url.AbsoluteUri.ToLower().Contains(Page.ResolveUrl(item.NavigateUrl.ToLower()))
{
item.Selected = true;
}
}
I would use jQuery in this instance.
For the specified page, so for example on the Analysis.aspx page, add this bit of jquery to your page.
$('#MenuItemID').addClass('active');
Can you specify the ID of the menu items?
Such as:
<asp:MenuItem ID="AnalysisMenuItem" NavigateUrl="~/Analysis.aspx" Text="Analysis"/>
You would then use this:
$('#' + <% AnalysisMenuItem.ClientID %>').addClass('active');
then of course just define what active is in your css:
.active { background-color: #FFF; }
If you are thinking to make it dynamically, then this is the better way:
Menu MyMenu = new Menu();
....
MyMenu.MenuItemDataBound += new MenuEventHandler(MyMenu_MenuItemDataBound);
TheMenu.StaticSelectedStyle.CssClass ="MySelectedClass";
protected void MyMenu_MenuItemDataBound(Object sender, MenuEventArgs e)
{
if (e.Item.NavigateUrl.ToLower().Contains(Path.GetFileName(Request.FilePath).ToLower()))
{
//e.Item.Text = "<div style='color: Yellow'>" + e.Item.Text + " </div>";
e.Item.Selected = true;
}
}
add then simply add .MySelectedClass style to your Css file
..
//Master
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu"
EnableViewState="False" Orientation="Horizontal"
BackColor="#465C71" DynamicHorizontalOffset="2"
ForeColor="#DDE4EC">
<StaticMenuItemStyle HorizontalPadding="15px" VerticalPadding="2px" />
<StaticSelectedStyle BackColor="#FFFFFF" ForeColor="#000000"/>
<Items>
<asp:MenuItem NavigateUrl="~/Secure/About.aspx" Text="About"/>
<asp:MenuItem NavigateUrl="~/Secure/Login.aspx" Text="Login"/>
</Items>
</asp:Menu>
//Master.cs
foreach (MenuItem item in ((Menu)this.FindControl("NavigationMenu")).Items)
{
if(Request.Url.AbsoluteUri.ToLower().Contains(item.NavigateUrl.ToLower().Substring(1)))
{
item.Selected = true;
}
}
//item.NavigateUrl.ToLower() contains "~". So, find substring and check.

ASP.NET Menu Image with Dropdown Text Subitems

I have a menu user control with image buttons like this one:
<asp:TableCell ID="tcDownload" runat="server" CssClass="MyMenuTableCellDownload" VerticalAlign="Top" >
<asp:ImageButton ID="ibtnDownload" runat="server" ImageUrl="~/Images/MyMenu/tb_download_1.gif"
CssClass="MyMenuIbtn" ToolTip="Download Results" />
</asp:TableCell>
In the codebehind, I handle the onclick for these to navigate to another page:
ibtnDownload.Attributes.Add("onclick", "document.location.href = '" + strNavUrl + "';return false");
Elsewhere in the user control, I have regular text menus like this one:
<asp:TableCell ID="tcMyMenuCust" runat="server">
<asp:Menu ID="menuMyCust" runat="server" StaticDisplayLevels="1" MaximumDynamicDisplayLevels="1" Orientation="Horizontal"
CssClass="MyMenuCustomer" StaticMenuItemStyle-ItemSpacing="0px" DynamicMenuItemStyle-CssClass="MyMenuDynamicItem"
StaticMenuItemStyle-CssClass="MyMenuStaticItem" DynamicHoverStyle-CssClass="MyMenuDynamicItemHover" DynamicVerticalOffset="0"
StaticHoverStyle-CssClass="MyMenuStaticItemHoverCust" StaticEnableDefaultPopOutImage="false"
DynamicPopOutImageUrl="~/Images/MyMenu/menu_arrow_grey.gif" DynamicMenuItemStyle-VerticalPadding="2"
DisappearAfter="0" OnMenuItemClick="menuMy_MenuItemClick">
<Items>
<asp:MenuItem Text="Customers" ImageUrl="~/Images/MyMenu/MyMenuGradientTransparent.png" Selectable="false">
<asp:MenuItem Text="Domestic "
Value="Customer_Domestic",
NavigateUrl="~/MyMain.aspx?_page=DomCusts&_title=DomesticCustomers">
</asp:MenuItem>
<asp:MenuItem Text="International "
Value="Customer_International"
NavigateUrl="~/MyMain.aspx?_page=IndCusts&_title=InternationalCustomers">
</asp:MenuItem>
</asp:MenuItem>
</Items>
</asp:Menu>
</asp:TableCell>
What I want to do is extend the menu choices by changing the image buttons to behave like the regular menus, while maintaining their look (image resource). That is, clicking on the image should result in a submenu dropping down to display subitems.
I know it's possible to use properties such as StaticEnableDefaultPopOutImage to indicate that a menu item has child items. I also understand that menu items can have background images, but what if I simply want to use an image rather than text on a main menu item that drops down subitems when clicked?
This turns out to be fairly straightforward. In the example above, I provide an ID for the top level item ("Customers") and remove the Text property, so that only the image refferred to in the ImageURL appears.

Resources