Asp.Net Form ... Accessabilty for dropdown elements - accessibility

I have an asp.net web page and I'm looking at different ways to make a form accessible.
On Example #1 I have a label that is associated to the drop-down, on Example #2 I have an Aria-Label tag with a description of the drop-down.
The original design had no labels for the drop-downs, so adding them kind of ruins the look and flow of the form. The drop-downs are used for filtering and are inline across the top of the page. Under the drop-downs are two buttons, one for filtering off of whats in the drop-downs and one to reset the form so it shows all results with no filtering.
My question is ... Is adding an Aria-Label tag acceptable, or is an associated label really required?
Example #1
asp:Label id="lbProgramName" runat="server" Text="Program Name:" AssociatedControlID="ddlProgramName
asp:DropDownList id="ddlProgramName" runat="server" CssClass="span5"
Example #2
asp:DropDownList ID="ddlProgramName" runat="server" CssClass="span5" aria-label="Program Names"

If you have a visual label (like your asp:Label with the AssociatedControlId attribute), you don't need the aria-label. The aria-label is used only when there is no association between a descriptive text and the control.

Related

How to make web radiobuttons work the way I want

I’m working on an asp.net page that simplified looks like this: A group of radiobuttons at the top, some asp dropdownlists in the middle and an asp button labled ”save” at the bottom. I want the page to work like this: When one radiobutton in the group has focus you should be able select one of the others by pressing the up and down arrow keys. At the same time different dropdownlists should be disabled or enabled depending on which radiobutton is selected. Then you select values from the enabled dropdownlists. Finally, by clicking ”save” values should be fetched both from the radiobuttons and the dropdownlists and passed via a procedure to a database. I’ve tried out html input radiobuttons, asp radiobutton and asp radiobuttonlist but have not managed to get the page to work the way I want it to. I’ll be very glad for help to a solution.
Write a project to display the flags of four different countries, depending on the setting of the radio buttons. In addition, display the name of the country in the large label under the flag picture box. The user also can choose to display or hide the form's title, the country name, and the name of the programmer. Use check boxes for the display/hide choices.

How to remove caption of field in DevExpress ASPxGridView EditForm

I am developing a custom column for DevExpress ASPxGridView.
At EditForm, I replaced the default edit textbox with a custom control that contains some other controls (label-textbox pairs).
Everything is working properly except one thing: since I have my own labels, I want to remove the edit form caption and expand my custom control to be rendered smoothly within the flow of other controls in the EditForm.
The EditForm is rendered as nested tables, then I am able to solve my problem manually in Chrome, by hiding the <td> that contains the caption, and expanding the colspan of the the <td> that contains my custom control, but I want to do this programmatically, how?
To hide column caption in the edit form, set the GridViewDataColumn.EditFormSettings.CaptionLocation property to ASPxColumnCaptionLocation.None

How can I make a repeater field editable?

I have a page with a repeater.. I have to make some fields of this one editable. I don't see how I can transform the repeater label into a textbox.. Can I use jquery to do that?
Have somebody make this kind of manipulation?
Thanks..
The Repeater control does not have an EditTemplate like many of the other data controls.
I would suggest having the edit fields either in a hidden Placeholder, then show this when clicking an edit button. This would involve the page posting back and then you having to show/hide the relevant parts in the ItemCommand handler.
Another way would be do add the edit fields/textboxs in a Panel control, then hide this through display: none;. Then you can change this to display: block; with some javascript. This will avoid the page PostBack.
This can be done in a Repeater, but a DataList control is more straightforward and is just as easy to use. There's an MSDN article on doing it in a Datalist control with full source code here: http://msdn.microsoft.com/en-us/library/bf5211wb(v=vs.71).aspx
Converting a repeater to a DataList is a much easier approach than having editable items in a Repeater.
HOWEVER
to answer your question directly, there IS a Codeproject sample here: http://www.codeproject.com/KB/aspnet/EditableRepeater.aspx
that shows how to use a Repeater with full edit functionality (including adding and deleting items).
To see the relevant code in the CodePlex article, search for the text "EditIndex". The relevant code-behind is always a few lines above and/or below this keyword.
It depends on how you want to do this:
using standart control probably you need GridView.
You can define the template for repeater and put TextBox there, then
on postback you will need to find dynamically created controls and
also you will need to take care to keep ID's of these controls the
same on postbacks.
And the other thing - you can replace label with the textBox using
jQuery and then update value via Ajax reques.
You decide what you need :) Anyway it's a lot of samples in the internet.

Custom CheckBoxList in ASP.NET

Since ASP.NET's CheckBoxList control does not allow itself to be validated with one of the standard validation controls (i.e., RequiredFieldValidator), I would like to create a UserControl that I can use in my project whenever I need a checkbox list that requires one or more boxes to be checked.
The standard CheckBoxList can be dragged onto a page, and then you can manually add <asp:ListItem> controls if you want. Is there any way I can create a UserControl that lets me manually (in the markup, not programmatically) insert ListItems from my page in a similar manner?
In other words, can I insert a UserControl onto a page, and then from the Designer view of the Page (i.e., not the designer view of the UserControl), can I manually add my ListItems like so:
<uc1:RequiredCheckBoxList>
<asp:ListItem Text="A" value="B"></asp:ListItem>
<asp:ListItem Text="X" value="Y"></asp:ListItem>
</uc1:RequiredCheckBoxList>
If a UserControl is not the appropriate choice for the end result I'm looking for, I'm open to other suggestions.
Please note that I am aware of the CustomValidator control (which is how I plan to validate within my UserControl). It's just a pain to write the same basic code each time I need one of these required checkbox lists, which is why I want to create a re-usable control.
An easier way to solve this problem is to use the standard CheckBoxList, but create a special server validator control specifically for the CheckBoxList. The following article shows you how to go about this - Creating Validator Controls for the CheckBox and CheckBoxList.

ASP.NET: An editable data bound control in every record?

We need to display the result of an SQL SELECT statement on a ASP.NET 3.5 web page. Although there are a number of columns that need to be displayed, only one of the columns needs an editable text box in it... however every record in the result set needs this editable textbox.
I know I can do this manually by building an html table myself, but I was hoping that there was a way to use a data-bound control (GridView? or ListView?) to do it.
Being somewhat new to ASP.NET, I am hoping there is some one out there who has done this.
--Thanks for your help!
A little further clarification....
We need all records to be editable immediately after display - so all records either need to be displayed in edit mode simultaneously - or the regular display mode needs to have an editable text box in it.
Use a GridView and convert the column that you want to be editable to Template.
In the ItemTemplate of this field, delete the Label and add a text box.
Add an extra "Save" button outside the GridView, and iterate the GridRows, find the text box (in each row), and use it to update the database.
Add a template column and then add a text box control instead of a label control
GridView BoundFields have the ReadOnly property which can be used to prevent the field from being edited in Edit mode. Set it to True for all columns that should not be editable.
<asp:boundfield datafield="myNonEditableColumn" Readonly="true" Headertext="My Non-Editable Column"/>

Resources