ASP.NET ajaxcontroltoolkit autocomplete ul overlay issue - asp.net

I have a following snippet of code in my ASP.NET application (simplified):
<asp:Panel ID="Panel7" runat="server">
<asp:TextBox ID="RecTextBox" runat="server" autocomplete="off" Height="18px" Width="800px"/>
<ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
CompletionListCssClass="autocomplete_completionListElements"
CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
CompletionListItemCssClass="autocomplete_listItem"
CompletionSetCount="20"
DelimiterCharacters=";, :"
Enabled="True"
MinimumPrefixLength="2"
ServiceMethod="GetCompletionList"
ServicePath="Rec.asmx"
ShowOnlyCurrentWordInCompletionListItem="True"
TargetControlID="RecTextBox" />
<br />
<asp:Button ID="Button3" runat="server" Text="Add" OnClick="Button3_Click" />
<asp:Button ID="Button11" runat="server" Text="Remove" OnClick="Button11_Click" />
<br />
<asp:Panel ID="Panel8" runat="server" Height="150">
<asp:ListBox ID="ListBox1" runat="server" Width="800" Height="150"></asp:ListBox>
</asp:Panel>
</asp:Panel>
Along with CSS classes:
.autocomplete_completionListElements
{
overflow : auto;
height : 130px;
list-style-type : none;
}
/* AutoComplete highlighted item */
.autocomplete_highlightedListItem
{
background-color: #ffff99;
color: black;
padding: 1px;
}
/* AutoComplete item */
.autocomplete_listItem
{
background-color : window;
color : windowtext;
padding : 1px;
left :0px
}
The problem is that autocomplete plugin renders an unordered list. It is contained in the document if autocomplete list is visible or not:
<ul id="ContentPlaceHolder2_TabContainer1_TabPanel2_AutoCompleteExtender1_completionListElem" class="autocomplete_completionListElements" style="position: absolute;"></ul>
When the autocomplete list is visible, there is no problem, because user is able to select desired autocomplete element. In turn autocomplete list is hidden, the unordered list is invisible but overlays multi select HTML controls (because ul has height : 130px;), and there are problems with selecting elements inside the multiselect:
Problem occurs in FF and Opera, but not in IE and Chrome.
Please for help,
Best regards,
WP

I found one possible solution based on Javascript:
1) Modify autocomplete_completionListElements CSS class - remove height : 130px; property.
.autocomplete_completionListElementy
{
overflow : auto;
list-style-type : none;
}
2) Assign Javascript handlers to following AutoCompleteExtender properties: OnClientShown, OnClientHidden
<ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
CompletionListCssClass="autocomplete_completionListElements"
CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
CompletionListItemCssClass="autocomplete_listItem"
CompletionSetCount="20"
DelimiterCharacters=";, :"
Enabled="True"
MinimumPrefixLength="2"
ServiceMethod="GetCompletionList"
ServicePath="Rec.asmx"
ShowOnlyCurrentWordInCompletionListItem="True"
TargetControlID="RecTextBox"
OnClientShown="autocompleteClientShown"
OnClientHidden="autocompleteClientHidden" />
3) Javascript handlers code:
function autocompleteClientShown(source, args) {
source._popupBehavior._element.style.height = "130px";
}
function autocompleteClientHidden(source, args) {
source._popupBehavior._element.style.height = "0px";
}

Related

Ajax modalpopupextender not popping up

.modalBackground
{
background-color: Gray;
filter: alpha(opacity=70);
opacity: 0.7;
}
.modalPopup
{
background-color: #ddffdd;
border-width: 3px;
border-style: solid;
border-color: Gray;
margin-top: 60px;
padding: 2px;
width: 400px;
font-size: 10pt;
}
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" CancelControlID="Button3"
OkControlID="btnOk" TargetControlID="LinkButtonDummy" PopupControlID="PanelPopUp"
BackgroundCssClass="modalBackground" />
<asp:Panel ID="PanelPopUp" runat="server" CssClass="modalPopup" Style="display: none">
<div>
<asp:Label ID="lblMsg" runat="server" />
<asp:Button ID="Button2" runat="server" Text="Add New Organisation" OnClick="Button2_Click" />
<asp:Button ID="Button3" runat="server" Text="Cancel" />
</div>
</asp:Panel>
I have also included the AJAX reference and a ScriptManager on the master page.
I have to add an enhancement to an existing page and I'm quite new with ASP.NET, the page in question is a 'content page' and is linked to a master page (containing the scriptmanager).
This code all looks completely fine and I have been reading on this for over three hours now but to no avail - my modal doesn't 'pop-up' and grey the background out, it simply appears where I have placed it on the page (right at the top, or right at the bottom e.t.c.) as if I was just showing/hiding a div.
Can anyone help, I'm going crazy?
What other routes can I go down for adding a confirmation box on a page that takes a string built in the code-behind and also runs code-behind functions on OK/Cancel?
Keep your css as it it and try this code :
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:ModalPopupExtender ID="MyPopup" runat="server" CancelControlID="Button3" OkControlID="btnOk" PopupControlID="PanelPopUp" BackgroundCssClass="modalBackground" DynamicServicePath="" Enabled="True"
TargetControlID="HiddenField1"></asp:ModalPopupExtender>
and on Button2_Click event add
MyPopup.Show();

Radio button text issue in ASP.NET

<asp:RadioButton ID="RadioButton3" runat="server" Text="Test" />
Getting radio button text in the next line (below the radio button) and facing table alignment issues in default.aspx, but the same code works fine with other web form pages.
How to fix this?
You can use display: block; to display RadioButton's text in next line.
Please make sure other CSS rules are not overriding this.
<style type="text/css">
.radiobutton label { display: block; }
</style>
<asp:RadioButton ID="RadioButton3" runat="server" Text="Test"
CssClass="radiobutton" />
<asp:RadioButton ID="RadioButton1" runat="server" Text="Test"
CssClass="radiobutton" />
<asp:RadioButton ID="RadioButton2" runat="server" Text="Test"
CssClass="radiobutton" />

Setting Checkbox ItemStyle ForeColor on ASP.Net DetailsView and GridView

On an ASP.Net DetailsView and also on a GridView I noticed that the tick mark in CheckBoxes are a light gray (disabled) colour even though I set it as blue.
<asp:CheckBoxField DataField="DayOfWeekMonday" HeaderText="Monday:" SortExpression="DayOfWeekMonday">
<ItemStyle ForeColor="Blue" />
</asp:CheckBoxField>
The same thing happens when the CheckBox is a TemplateField.
<asp:TemplateField HeaderText="Monday:" SortExpression="DayOfWeekMonday">
<EditItemTemplate>
<asp:CheckBox ID="CheckBoxEditDayOfWeekMonday" runat="server" Checked='<%# Bind("DayOfWeekMonday") %>' />
</EditItemTemplate>
<InsertItemTemplate>
<asp:CheckBox ID="CheckBoxInsertDayOfWeekMonday" runat="server" Checked='<%# Bind("DayOfWeekMonday") %>' />
</InsertItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBoxItemDayOfWeekMonday" runat="server" Checked='<%# Bind("DayOfWeekMonday") %>' Enabled="false" />
</ItemTemplate>
<ItemStyle ForeColor="Blue" />
</asp:TemplateField>
I also tried this in the code-behind file.
Protected Sub CheckBoxItemDayOfWeekMonday_DataBinding(sender As Object, e As EventArgs)
Dim theControl As CheckBox
theControl = DetailsView.FindControl("CheckBoxItemDayOfWeekMonday")
theControl.ForeColor = Drawing.Color.Blue
End Sub
Is there a way to change it to blue like the rest of our fields and columns?
I noticed you meant the tick mark INSIDE the checkboxes, not the forecolor. I don't think you can change this as this is very OS dependant. I have implemented this with images in the past. You can try these CSS3 CheckBoxes which uses images: http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/quick-tip-easy-css3-checkboxes-and-radio-buttons/
Sample:
HTML:
<span><input type="checkbox" id="c1" name="cc" />
<label for="c1"><span></span>Check Box 1</label>
</span>
CSS:
input[type="checkbox"] {
display:none;
}
input[type="checkbox"] + label {
color:#000000;
font-family:Arial, sans-serif;
font-size:14px;
}
input[type="checkbox"] + label span {
display:inline-block;
width:19px;
height:19px;
margin:-1px 4px 0 0;
vertical-align:middle;
background:url(http://webdesigntutsplus.s3.amazonaws.com/tuts/391_checkboxes/check_radio_sheet.png) left top no-repeat;
cursor:pointer;
}
input[type="checkbox"]:checked + label span {
background:url(http://webdesigntutsplus.s3.amazonaws.com/tuts/391_checkboxes/check_radio_sheet.png) -19px top no-repeat;
}
JSFiddle: http://jsfiddle.net/4FraV/2/

How can I ensure that the top level menu item has a CSS class of selected while clicking sun-menu?

I have two ASP.NET 4.0 Menu controls for tabs and sub-tabs & one tree control for left side navigation on a page.
I'm using the selected CSS class to ensure that the selected tab/sub-tab/navigation is in different color.
Whenever i select one of these control's item, selected CSS applied on it but parent selection state lose.
How can I ensure that the top level menu item has a CSS class of selected when viewing a sub page?
Main Menu:
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" />
<asp:Menu ID="mainMenu" runat="server" Orientation="Horizontal"
MaximumDynamicDisplayLevels="0" RenderingMode="Table"
DataSourceID="SiteMapDataSource1"
ViewStateMode="Enabled">
<StaticMenuStyle CssClass="menu"/>
<StaticMenuItemStyle CssClass="menuItem"/>
<StaticSelectedStyle CssClass="menuSelectedItem"/>
</asp:Menu>
Sub Menu:
<asp:SiteMapDataSource ID="SiteMapDataSource2" runat="server" ShowStartingNode="false" StartingNodeOffset="1"/>
<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal"
MaximumDynamicDisplayLevels="0" RenderingMode="Table"
DataSourceID="SiteMapDataSource2"
ViewStateMode="Enabled">
<StaticMenuStyle CssClass="menu"/>
<StaticMenuItemStyle CssClass="menuItem"/>
<StaticSelectedStyle CssClass="menuSelectedItem"/>
</asp:Menu>
Left Navigation:
<asp:SiteMapDataSource ID="SiteMapDataSource3" runat="server" ShowStartingNode="false"
StartingNodeOffset="2" />
<asp:TreeView ID="TreeView1" runat="server"
DataSourceID="SiteMapDataSource3"
ExpandDepth="2" NodeIndent="0">
<ParentNodeStyle Font-Bold="False" />
<HoverNodeStyle ForeColor="#5555DD" />
<SelectedNodeStyle BackColor="GhostWhite"/>
<NodeStyle BackColor="LightSteelBlue"/>
</asp:TreeView>
CSS:
.menu
{
background-color: black;
font-size: 12px;
font-family: Arial;
font-weight: bold;
}
.menuItem td
{
height: 24px;
width: 120px;
background: url(Images/unselectedTab.jpg) no-repeat;
text-align: center;
vertical-align: middle;
}
.menuSelectedItem td
{
height: 24px;
width: 120px;
background: url(Images/selectedTab.jpg) no-repeat;
text-align:center;
vertical-align:middle;
}
Did not read your code but according to me if you want to preserve parent menu item selected then you will have to check in your code that it is not getting removed. In your scripts there may be some code like -
$(this).parent().removeClass("selected");
Comment this line if it is present and check whether it works or not. If there is no such thing then you will have to apply class as below -
$(this).parent().addClass("selected");
Both of the above code line, you will find inside the function which is called on click of a menu.

How do I apply a style to all buttons of an ASP.NET web page

Somebody asked similar question not long ago. But nobody answered comprehensively.
Assume I have:
<asp:Button id="b1" Text="Submit" runat="server" />
<asp:Button id="b2" Text="Submit" runat="server" />
I want to set the following property to both buttons:
height: 100px;
width: 50px;
Let's say both properties are included in a class. How do I apply that class into both buttons?
Thank's
Method 1
Add a CSS stylesheet with the following selector.
input[type="submit"] {
height: 100px;
width: 50px;
}
Method 2
Use an ASP.Net Theme.
Method 3
Set a class name on each button using the CssClass property.
Markup:
<asp:Button id="btn1" Text="Submit" CssClass="buttonStyle1" />
<asp:Button id="btn2" Text="Submit" CssClass="buttonStyle1" />
<asp:Button id="btn3" Text="Submit" CssClass="buttonStyle1" />
<!-- the class can be applied to any number of other elements -->
CSS:
.buttonStyle1 {
height: 100px;
width: 50px;
}
just give them the same class for css
<asp:Button id="b1" CssClass="TestStyle" Text="Submit" runat="server" />
<asp:Button id="b2" CssClass="TestStyle" Text="Submit" runat="server" />
.TestStyle
{
height: 100px;
width: 50px;
}

Resources