I am implementing the Autocomplete textbox from AjaxControlToolkit in ASP.NET. The ServiceMethod allows me to call a function which will populate a string list with which to populate the autocomplete list that will display.
My question is, when I call the database, I would like to store an ID that corresponds with each selection, so that once it is selected by the user, I can easily look it back up in the database. I don't want to display it in parentheses next to the selection (ie. "John Smith (ID1234)", etc.)
Is there a way to do this so that the ID is 'hidden' so to speak within the Autocomplete box, and can be retrieved on selection? Should i use a different autocomplete box to accomplish this? Any help is greatly appreciated. Thanks!
This might answer your question
http://www.aspsnippets.com/Articles/Fetch-multiple-values-as-Key-Value-pair-in-ASP.Net-AJAX-AutoCompleteExtender.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 have an requirement to create a list type structure and that will be the options kind of thing.So, when user check the checkboxes or in other words select the options, I have an box equally opposite to it which will show the seleceted options. for eg
The first box contains this::
checkbox Investemnt-1102
checkbox credit-rt11
checkbox debit -2390
the seocond box will list all the items that are selected from first box
as I am new to MVC, I am confused for the first thing that I am not using any third party control.I need to do it custom .so, How can I make it possible. Please suggest.
You can always create custom Helpher extended controls in MVC. This is the beauty of MVC.
Do you want something like this?
MvcCheckBoxList
You can play around with your logics easily.
Here is the detailed description of above extension
http://www.codeproject.com/Articles/292050/CheckBoxList-For-A-missing-MVC-extension
Do google and read about Extensions
I am very new to ASP.NET and this is my first job and I need to perfom good.
I am stuck on this search page where I have two text boxes. One searches by ID which is int, the second by last name. Both the searched populate a grid view. As per the requirement when the user types in last name and clicks search the grid view should populate which I got working. Now if the user stats typing in the ID Search text box the Lastname Search text box should clear as well as the grid view that had gotten populated should be hidden.
I achieved clearing the text box by using
txtSNumberSearch.Attributes["onKeyDown"] = "clearTextBox(this.id)";
txtSNumberSearch.Attributes.Add("onKeyDown", string.Format("document.getElementById('{0}').innerText='';", txtLastNameSearch.ClientID));
txtLastNameSearch.Attributes.Add("onKeyDown", string.Format("document.getElementById('{0}').innerText='';", txtSNumberSearch.ClientID));
But am not able to clear or hide the grid view on key down in the text box, my boss says I need to create a custom key down event handler. I do not know how to do it. Any help would be appreciated as I really need to perform at this job.
An easy way of hiding the GridView is by simply adding it into a standard div and hiding that.
<div id="divGV">
<asp:GridView>...
</div>
You can hide the div by doing this in javascript:
document.getElementById("divGV").style.display='none';"
You've already got a handler added for txtLastNameSearch, so you could do something like this:
txtLastNameSearch.Attributes.Add("onKeyDown", string.Format("document.getElementById('{0}').value='';
document.getElementById("divGV").style.display='none';", txtSNumberSearch.ClientID));
Text boxes don't use InnerText. Try using value property. Keydown is just fine I think.
Try this.
txtSNumberSearch.Attributes["onKeyDown"] = "clearTextBox(this.id)";
txtSNumberSearch.Attributes.Add("onKeyDown", string.Format("document.getElementById('{0}').value='';", txtLastNameSearch.ClientID));
txtLastNameSearch.Attributes.Add("onKeyDown", string.Format("document.getElementById('{0}').value='';", txtSNumberSearch.ClientID));
I have a listview that is connected to a datasource. When I view the project in a browser, the listview is populated with data from the Northwind database. I just have the CustomerID and ContactTitle columns displayed. I want to be able to click on the CustomerID and then display the rest of the information about that particular customer. I've searched and searched and searched and tried a ton of different things but I just can't figure out how to make the CustomerID clickable. I am using c# and ASP.NET. Any help would be greatly appreciated.
You want to create a itemTemplate that contains various controls and bind the columns of your datasource to those controls. For the field in question you want to make sure you select a "clickable" control. like a link, button or even a div, and then create a handler for that click event. A good example of such a thing can be found in MSDN here: http://msdn.microsoft.com/en-us/magazine/cc337898.aspx
Do your list items contain li's? Whatever tag you use, you would use the javascript onclick event on each li to initiate whatever action you require.
If you need to retrieve customer data you could initiate a postback from your javascript to retrieve the data and display the customer details.
in my Application i have text box beside it i have drop down control.
when the user clicks on the drop down . a list of items under the drop down control should be shown. but if user type any value in the text box ( like tom, james, peter). if that value is there in the drop down . i should move the cursor to that value.
hope my Question is clear.
Any solution how to solve it would be great
thank you
what are you looking is,
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ComboBox/ComboBox.aspx
Just check it, Its autocomplete with dropdown
Sounds like you want something like the JQuery autocomplete plugin or if you prefer the ASP.NET AJAX Autocomplete control.
Edit- as you want a Combobox- JQuery has a lot of options for this. Here is one of them "Simple Combo".