I have an asp dropdownlist loaded with cities/countries. They are loaded directly in code
<asp:ListItem Value="MIA">Miami, Florida</asp:ListItem>
I would like to extend the control with Ajax in order to allow a user to start typing and show similar matching options from a dropdownlist below. Is this possible using this control and the hard coded values? Thanks!
The behaviour you describe is usually achieved by extending the textbox control rather than dropdownlist.
Microsoft has a lot of useful tutorials on its asp.net website; try this one: http://www.asp.net/AJAX/AjaxControlToolkit/Samples/AutoComplete/AutoComplete.aspx for a start.
If you want to write your own control, I have written a blog about some of the gotchas when adding values to a DropDownList via javascript
http://blog.runxc.com/post/2009/04/27/Using-jQuery-to-add-values-to-a-DropDownList-and-overcoming-ASPNET.aspx
Related
I am looking for a textbox in C# which should work like dropdown search values when I type anything in the textbox. Those values will come from calling a method.. and I Should be able to select any of the values.
Do i need to use the asp dropdownlist or is there any other sample code available which could help me.
You should look into jQuery autocomplete feature.
http://jqueryui.com/autocomplete/
The ajax control toolkit provides Autocomplete extender to do just that. The control calls a method, which you specify, asynchronously and get all the values to be shown as an option. I would imagine these values would be retrieved when the page loads and will not be session specific so can be stored in a cache for faster retrieval.
http://www.asp.net/AjaxLibrary/AjaxControlToolkitSampleSite/AutoComplete/AutoComplete.aspx
i want to create a web page with a textbox and a gridview.
as you type in the textbox i want the content of grid view to be retrieved from database according to the text of textbox.
i am also using ajax.
is there any way to get the text from textbox as user types in and pass it to the server side code?
i searched on google but the only thing i got was keypress event using jquery or java and display it using java again. but there was nothing about passing it to the code behind.
Thanks and pardon my poor English :(
In asp.net you can specify the AutoPostBack="true" on a textbox this will fire an postback after you lose focus of that TextBox, so not on every keystrike if you desire to have a postback on every keystrike you will have to implement some javascript knowledge.
Here you can find an example:
How do I make a Textbox Postback on KeyUp?
But I believe you are more interessted in a AutoCompleteBox maybe give this link a try:
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AutoComplete/AutoComplete.aspx
As you said, you can use the java key press event. Then you can create an ajax request and ask the server for data.
You should make sure that the data you are requesting can be retrieved very fast, otherwise you would have a delay when typing. Maybe it's a better approach to fetch the whole result and filter it while typing.
A small example can be found here: Making a Simple Ajax call to controller in asp.net mvc
Other examples can be found with your friend google.com :-)
i need a solution like this:
http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/checkboxes/defaultcs.aspx
however, i need the user to be able to add entries in here.
does such a control already exist?
it can be either jquery or asp.net
it also does not have to be a combobox, it can be a listbox. i need to have every item have a checkbox next to it and be able to add a comment for each entry.
Take a look at the ASPxGridLookup control from the DevExpress component vendor.
The ASPxGridLookup component allows the implementation of the multi-select DropDown functionality:
http://demos.devexpress.com/ASPxGridViewDemos/ASPxGridLookup/MultiSelect.aspx
http://www.devexpress.com/example=E3467
http://codecentral.devexpress.com/E3467/
with editing capabilities via the embedded ASPxGridView object:
http://demos.devexpress.com/ASPxGridViewDemos/GridEditing/EditModes.aspx
Ref : DropdownList with Multi select option?
Multiple dropdownlist with checkbox....checkout below link...
checkout demo page here...
http://download.ysatech.com/ASP-NET-Multiple-Selection-DropDownList/ASP-NET-Multiple-Selection-DropDownList.aspx
Blog page here....
http://blog.ysatech.com/post/2009/09/09/ASP-NET-Multiple-Selection-DropDownList-with-AJAX-HoverMenuExtender.aspx
http://www.codeproject.com/KB/user-controls/MultiSelectDropdownList.aspx
To me it sounds like it might be better for you to run with a ListBox. Telerik offers the RadListBox, which allows you to have checkboxes as seen here.
Additionally, you could allow for edits upon, for example, double-click as is displayed in the source code attached to this forum post.
Finally, if you want to also display the comments then you could use an ItemTemplate to define a custom layout for each RadListBoxItem and allow the user to edit both the main and comment fields.
That should cover everything that you need.
I am using ASP .NET (C#) and have a page with a listview linked to a sqldatasource.
The listview has a InsertItemTemplate which contains many textboxes. I want to make all the textboxes required via the RequiredFieldValidator (and the ValidatorCallOutExtender).
Is there a way to do this in the codebehind instead of the aspx page?
Ideally I would like the page to validate each control with the same method with only the error message changing.
I take it your question is about dynamically adding controls (and not about codebehind validation).
I didn't know and ran a few tests. It is possible to simply add (Validator)controls to the Controls property of the Form element, but controlling the order is not so simple (no Controls.Insert()).
So my advice would be not to use a plain TextBox but a UserControl. You could probably use Search&Replace to fix up the ItemTemplate.
I would like to move items from one list to another on a page, and I'm pretty flexible about what type of a list it is. What's the best way to do that? ASP.NET Ajax? jQuery? Anything else?
There's a nice tutorial on CodeProject that covers dragging with ASP.NET and jQuery:
http://www.codeproject.com/KB/webforms/JQueryPersistantDragDrop.aspx
if you want to do this and PostBack instead of using AJAX to update your data based on from fields you'll need to get creative about what types of controls you use. Page validation will complain about ASP controls like dropdownlists, listboxes, etc. if they contain selected items that weren't in the list when it was rendered.
Better to use AJAX to send back your updates or use HTML controls like unordered lists or select added via javascript and stuff the selected data in another control that doesn't complain (hiddenfield) on PostBack. The alternative is turning off page validation and I don't think that's a good idea.
You can also might look at YUI Library, I'd say it implements Drag & Drop in a very simple and flexible way:
http://yuilibrary.com/yui/docs/dd/
There are a lot of examples etc...