473,398 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Highlight dropdownlist value based on value enterd in textbox

390 Expert 256MB
I have one webapplication(.net2.0)c#.

My page has one dropdownlist which is very huge sometimes it contains many records which is difficult for the users to view the data they exactly looking for.

What we want to do now is we want to add a textbox on the top of the dropdown and once user enter any data on textbox we want to select the firstrow in the dropdown which start from the letter they entered in textbox.

Can this achieved some way either in c# or javascript.
Sep 27 '10 #1
4 2782
Frinavale
9,735 Expert Mod 8TB
I think I would use JavaScript for this task. I would handle the onkeyup event for the TextBox and search for anything that matches what is in the TextBox using regular expressions.

-Frinny
Sep 27 '10 #2
mzmishra
390 Expert 256MB
Thanks Frinny.
That's what exactly I am doing now.
Wrote a javascript function and calling that for both onkeyup and onchange event of textbox.
Sep 27 '10 #3
Frinavale
9,735 Expert Mod 8TB
:)
I don't think you'll need the onchange because the onkeyup should cover it.
Sep 27 '10 #4
mzmishra
390 Expert 256MB
Finny,

I got one more issue.

What I did is I add this code and javascript function.Now I am getting my results properly.
But my problem is when I highlight that row and user clicks it I want to fire the onselectedevent change for dropdown.


Now for my case it won't work because my selected row is now the displayed one.I want the behaviour to be similar to highlighting a dropdown and pressing a key, which will then take you to the first instance of the dropdown item that starts with the letter pressed.


Is there any idea how to achieve
My code

Expand|Select|Wrap|Line Numbers
  1. function filtedropdown(pattern, list){
  2.  
  3.     if (!list.bak){
  4.  
  5.     list.bak = new Array();
  6.     for (n=0;n<list.length;n++){
  7.     list.bak[list.bak.length] = new Array(list[n].value, list[n].text);
  8.     }
  9.     }
  10.  
  11.     var selectedItempos=0;
  12.     for (n=0;n<list.bak.length;n++){
  13.     var indexOfLastName=list.bak[n][1].indexOf(',');
  14.     var lastNameSubstring=list.bak[n][1].toLowerCase().substring(0,indexOfLastName);
  15.     if((lastNameSubstring.toLowerCase().indexOf(pattern.toLowerCase())!=-1) 
  16.         && (lastNameSubstring.toLowerCase().indexOf(pattern.toLowerCase())==0)){
  17.     selectedItempos=n;
  18.     break;
  19.     }
  20.     }
  21.     list[selectedItempos].selected=true;
  22. }
  23. <asp:Panel id="pnlProviderList" runat="server" visible="false">
  24.                      Skip to letter:&nbsp;
  25.                      <input type="text" name="txtSkip" onkeyup="filtedropdown(this.value,<%= ddlProvider.ClientID %>)" onchange="filtedropdown(this.value,<%= ddlProvider.ClientID %>)"/>
  26.                         &nbsp; Provider:
  27.                         <ewc:EmblemDropDownList runat="server" ID="ddlProvider" AutoPostBack="true"
  28.                          OnSelectedIndexChanged="ddlProvider_SelectedIndexChanged" />
  29.                     </asp:Panel>
Sep 29 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Richard G. | last post by:
Hi All, I am newbie in XML. I am designing a dynamic menu and retrieving data from xml. I have the xml file something like this: <?xml version="1.0" ?> <ROOT>
1
by: CoreyMas | last post by:
Hello everyone, Here is my situation I created an HTML text box that contains a value that is calculated using Javascript. I expose this control so that .Net sees it, but when I go to...
1
by: TRAX | last post by:
Here's my problem: I've got a table cities with the following tables: zipcode, city, province and table provinces: a table with: province_id, provincename cities.province and province.province_id...
10
by: MLH | last post by:
Would like to examine the value entered into a textbox on an A97 form during the BeforeUpdate event. The textbox may or may not have had an earlier entry in it prior to the latest value that is...
2
by: Eph0nk | last post by:
Hi, I don't know a lot about javascript - and i'm stuck on a certain problem. I need to put a value in an <asp:textbox> control from a javascript. The textbox is called "txtThumb" - and the...
11
by: garyusenet | last post by:
I have 'cli via c# on order', and in the mean time am reading 'Pro C# 2005 and the .NET platform' (Andrew Troelson). I'm just reading about the 'five types defined in the CTS'. Specifically Struct....
1
by: aekta | last post by:
Hello all, How we get The Value of Dynamic generate TextBox in asp.net? i have a web form and in which i want to create textbox dynamically by click on Button ...Now,on another button click I...
0
by: mervyn | last post by:
Hi There, I am very new to .NET and VB so this may be a really simple thing to solve but here is my issue I have a a textbox with a value in it. I know what the length of the text in the text...
0
coolv
by: coolv | last post by:
Hello Everyone I want to Reload Second Dropdownlist from selected value of first Dropdownlist using Ajax in ASp.NET Also I want a to make validation using Ajax on page. Can anyone help me. ...
0
coolv
by: coolv | last post by:
Hello Everyone I want to Reload Second Dropdownlist from selected value of first Dropdownlist using Ajax in ASp.NET Also I want a to make validation using Ajax on page. Can anyone help me. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.