.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Trap Selected Index change event of listbox using Javascript.

Posted By:      Posted Date: September 02, 2010    Points: 0   Category :ASP.Net
Hi All, This is reagarding listbox selection. I have a list box with multi select option. I want to trap the selected index change event of Listbox through javascript. Item of list box can be selected using Click of mouse and also the keyboard up down key with shift. I tried onclick event to bind the javascript function. It works fine if I select by mouse, but it doesen't work for up/down key of keyboard. Thanks, Naveen

View Complete Post

More Related Resource Links

How to Capture a DropDownList Selected Index Change Event

I have a gridview that receives data based on selection from a primary dropdownlist object. Works. Within the gridview, there is a dropdownlist whose selected index is based on the query from the primary dropdownlist. Works. Problem. How do I force the used to  change whatever value that the dropdownlist contains after they make their initial selection from the primary dropdownlist; except the default value of "Please make a selection". Gridview, contains a checkbox which drives whether a selected row is inserted into the data base. The databind in done using an ObjectDataSource on the presentation page, not in the code behind.   Thank you.   Ayomide 

Drop Down Listbox SelectedIndexChanged Event not firing when I programmatically change selection

I have two drop down listboxes (DDL1 and DDL2).  When DDL1 has an index change, DDL2 then has a refresh of list items based off SQL Server SELECT from a table.  The database isn't the problem.  Everything works perfectly when the user selects a new item manually from DDL1.But in my code, I save the user data from the selection of DDL1 in a separate table.  And then upon rendering of the page (Page_PreRenderComplete), I do a SelectedIndex assignment of the value of what's saved in the db table.  That works just fine, it selects the DDL1 item, but DDL2 is unaffected, as if DDL1's SelectedIndexChanged event isn't called like it would be if manually changed.  How can I get around this?Thanks in advance. :)

Change selected row background color in gridview using javascript


hi frineds,

              i have a gridview with radio buttons in gridview i have chance to select only one item at a time in gridview like this

i need to change the row color of selected item in gridview with radio button using javascript if i select second row with radio button first row comes to normal condition now second row is in selected mode please help to write this functionality using javascript

gridview dropdownlist selected indeex change event



I bind the ddl as name column in gridview and age as textbox in the next column.

 void bind()


 SqlCommand com = new SqlCommand("Select id,name from employee", con);

SqlDataAdapter da = new SqlDataAdapter(com);

DataSet ds = new DataSet();


GridView1.DataSource = ds;


SqlDataAdapter da1 = new SqlDataAdapter("select id,name from employee", con);

DataSet ds1 = new DataSet();


for (int i = 0; i < GridView1.Rows.Count; i++)


 DropDownList ddl = (DropDownList)GridView1.Rows[i].FindControl("ddlname");

ddl.DataTextField = "Name";

 ddl.DataValueField = "Id";

ddl .DataSource = ds;




the above coding i fallow but in selelected indexchange event i have to dispaly the age of particular name in gridview.

ListBox Selected index Changed in a TabControl


Hello Folks,

again i need your help!

As you can see in the picture below i've got a Page control with inital letters which cotains a listbox showing different wood articles.
When i click on a Tab, the selected tab page get's a new Listbox control with the wood articels starting with the selected initial letter.

Creating the listbox:

 _woodList = (WC_WoodList)LoadControl(PageNames.WOODLIST);
            _woodList.InitialLetter = tabWoodLetters.ActiveTabPage.Text;

if (!String.IsNullOrEmpty(initialLetter))
                DataSet _temp = fuData.GetWoodSpecies(initialLetter);

                listboxGeneric.DataSource = _temp.Tables[0];
                listboxGeneric.ValueField = "BEZEICHNUNG";
                listboxGeneric.TextField = "BEZEICHNUNG";

                listboxGeneric.Height = _temp.Tables[0].Rows.Count * 19 + 3;


 When i click on a item inside the listbox, following code will be executed:

C# listBox ScrollIntoView doesn't scroll to Selected Index


I have a WPF window that includes several ComboBoxes and ListBoxes. I have a button that is meant to reset the selected item in all the ComboBox and ListBox to the top item. This is designed to allow the User to "reset" their search parameters.

The programmatic selection of Index 0 works for all the boxes but the ListBox is presenting a problem. When I programmatically select index 0 in the ListBox it doesn't scroll to the selected Item. Because of this the user isn't immediately aware that the selection has been moved to the top item.

Here is the code I'm using:

private void button3_Click(object se

how to impose javascript event processing?


If I have some form control like textbox and I want the event handler to be located in the html instead of at the server side, how to do that? Of course I can copy paste javascript code in the aspx file. But is it possible to do that using some object oriented approach (ie programmatically in the code behind)?


Selected to change the background color of the page



As this site, http://www.borfin.com.tr/genel/Default.aspx, How can I change the background color selected pages.

Closing Javascript Modal dialog window after server side event processing


Hello Friends..

Please tell me how to close Javascript ModelDoalog Window.. after Server Side event Processing .

Basically i want close window in  finally Block After sucessfulll Updation.

AMit..... InnocentInnocentInnocentInnocentInnocentInnocentInnocent

dropdownlist javascript change items


I can't find solution for this problem for very long time:

I have dropdownlists in Gridview. I need to dinamicly change content of dropdown on client with javascript. Ok, I know to do that. But the problem is when I send data to server changes in dropdownlist does not see. On server I have  old items. How can I change items in dropdown on client with javascript and than see that items on sever when postback data?


How can I change values in mydetailsview_ ItemInserting event

I'm inserting values with detailsview, and I want to modify one of my values and my client should not see it.

This is my detailsview:

<asp:DetailsView ID="dv_InsertTaps" Runat="server" DataSourceID="ds_InsertTaps" DataKeyNames="TapId"
AutoGenerateRows="False" DefaultMode="Insert" title="INSERTAR TAPS" OnItemInserting="dv_InsertTaps_ItemInserting">
<asp:TemplateField SortExpression="TapNumero" HeaderText="N&#186; Tap"><InsertItemTemplate>
<asp:TextBox Runat="server" Text='<%# Bind("TapNumero") %>' ID="tb_TapNumero"></asp:TextBox>
<asp:BoundField HeaderText="Valor" DataField="TapValor" SortExpression="TapValor"></asp:BoundField>
<asp:BoundField HeaderText="Alta Frecuencia" DataField="TapAF" SortExpression="TapAF"></asp:BoundField>
<asp:BoundField HeaderText="Baja Frecuencia" DataField="TapBF" SortExpression="TapBF&quo

change form target from javascript


Salam to all,

in my page, i have an iframe which have a src for another page,

the inner page have a Forms, buttons.. ..etc. the target for the form in the inner page is "self"

i need to run a javascript code from the parent page to change the  inner page form target to posted the values in a Blank window.

how can i do that ?


Can't change Gridview row colors or styles in the DataBound event


I was highlighting certain rows in my gridview using code like this in the DataBound event:

        if (e.Row.RowType == DataControlRowType.DataRow)
            int vendorCheck = 0;
            //TODO make this shorter
            if (DataBinder.Eval(e.Row.DataItem, "vendorId") != System.DBNull.Value)

Javascript code to copy selected dropdown item to clipboard

Does anyone know how I can do this to get the text onto the clipboard?  <input id="Copy" type="button" value="Copy Url" runat="server" onclick="copy();" style="vertical-align: top;" visible="false"/><script type="text/javascript"> function copy() { var sel = document.getElementById("DropDownList1"); var text = sel.options[sel.selectedIndex].value; ??? } </script> </body>  

Change RadMaskedTextBox value via javascript

Hi All,I am using RadMaskedTextBox in my web page. I am trying to set its value through javascript. It works ok if i hard-code control name (i.e. rtHours11_1) in the script as following: var radMaskedTextBox1 = window["<%= rtHours11_1.ClientID %>"]; radMaskedTextBox1.SetValue("00:00"); But I want to set the control name dynamically as this function will be called for many controls on the page. Can someone help me to modify it in the way that it will accept the control name dynamically as following: function InitilizeMe(thisCtrl) { var radMaskedTextBox1 = window["<%= thisCtrl.ClientID %>"];  radMaskedTextBox1.SetValue("00:00"); } Thanks in advance for your help.Regards.

how do i use javascript to change values of controls inside a gridview

i have 2 labels (lblRate,lblTotal) and a textbox (txtQuantity) in a itemtemplate of a gridview.I want to calculate the products of rate and quantity and show it in Total as the textbox loses focus...i cant use textchanged because i dont want the page to postback.How do i use javascript to achieve this??Please Help Urgently....<asp:TemplateField HeaderText="Rate">                <ItemTemplate>                    <asp:Label ID="lblRate" runat="server" Text='<%# Eval("Rate") %>' />                </ItemTemplate>            </asp:TemplateField> <asp:TemplateField HeaderText="Quantity">                <ItemTemplate>                    <asp:TextBox ID="txtQty" runat="server" />                </ItemTemplate>&

How can I change the SelectedIndex on a listbox when another listbox is doubleclicked?

Here is my xaml. <     StackPanel>       <ListBox x:Name="List1">       <ListBoxItem>Part 1</ListBoxItem>       <ListBoxItem>Part 2</ListBoxItem>       <ListBoxItem>Part 3</ListBoxItem>       <ListBoxItem>Part 4</ListBoxItem>       <ListBox.Triggers>       <EventTrigger RoutedEvent="ListBox.MouseDoubleClick">       <BeginStoryboard>       <Storyboard Duration="00:00:00">       <Int32Animation Storyboard.TargetName="List2" Storyboard.TargetProperty="SelectedIndex" From="-1" To="0" Duration="00:00:00" FillBehavior="HoldEnd"></Int32Animation>       </Storyboard>       </BeginStoryboard>       </EventTrigger>       </ListBox.Triggers>       </ListBox>       <ListBox x:Name="List2">       <ListBoxItem>Section A</ListBoxItem>       <ListBoxItem>Section B</ListBoxItem>
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend