.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

remove onchange event of Dropdownlist using JS

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :ASP.Net


I m trying to stop the postback causing by ddl. I have tried the following code but still pb doesnt stop:

Any suggestions please.

<script type="text/javascript" language="javascript">
	var ddlSubCategory = document.getElementById("ctl00_m_g_73a5a887_bd36_4a37_966a_ed640c804a84_ctl00_ctl04_ctl09_ctl00_ctl00_ctl04_ctl00_ctl00_SubCategory"); //Get this form html source 
	ddlSubCategory.removeAttribute("onchange"); //Here "onchange" attribute causes post back

View Complete Post

More Related Resource Links

Need to remove databinding of DropdownList when another dropdown list changes


I have many controls on my form, but in particular, I have 2 dropdownlists.  1 dropdown list has 2 values, and each value controls what the second dropdownlist displays.  This is an edititemtemplate and both dropdowns have the selecteditem set via '<%# Bind("fieldname") #>' on page load.  

THe problem is, if I change the value of the first dropdown, it errors out because the second dropdwon has a bound value that is no longer acceptable. 

Can I cancel the bind of the second control, if the the first one is changed?  I would like to cancel the bind, and update the values by using a different datasource depending on the value of the first dropdown or hardcode the new values.



If Dropdown1 has a value of "A" for example Dropdown 2 Shows Values "1", "2", "3"

If Dropdown 1 has a value of "B" , Dropdown2 Shows Values "4", "5", "6".

It binds fine initially, but if I change Dropdown1 from A to B, I want Dropdown2 to show the new values, maybe with a default of "Select an Item" and not error out b/c it's attempts to bind a value of 1, 2, or 3.


Hope this makes sence, b/c I'm

Get dropdownlist event OnSelectedIndexChange using jquery

I have dropdownlist that located inside a repeater, how can i get OnSelectedIndexChange event of this dropdownlist? i want to use this event to set TextBox value olso inside this repeater, i try this code$("#Table1> tbody > tr ").each(function() { var rowId = $(this).attr("id"); $(this).find("td > #DropDownList1").change(function() { $("#" + rowId + "> TD:nth-child(6) > input[name$='TextBox1']").val("Test"); }); }); But did not work, can anyone please help me?

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 

Dynamic DropDownList ListItemCollection - Event Handler

Hi and thanks in advance. Description: I am building drop downs dynamically then adding them to a panel, when postback occurs it does not hit my event handler. However I CAN get the event handler to be hit if I remove(comment out) the properties DataTextField and DataValueField while I am rebuilding the dropdownlist within OnInit on eachpostback. However when the dropdownlist is in this condition the sender to the eventhandler does not have it's properties like SelectedValue[Index] set. Step 1: Build and load a drop down. The following is the event handler for selectedindexchanged on the lists.  The drop down list is bound to a ListItemCollection that represent a few fields from a datatable. This dropdown is loaded into a panel and the panel in turn is loaded into a div. All of this functions as intended.protected void AnswerDDL_SelectedIndexChanged(object sender,EventArgs e) { int _nextQuestionID; DropDownList _ddlSender = new DropDownList(); _ddlSender = (DropDownList)sender; _nextQuestionID = Convert.ToInt32(_ddlSender.SelectedValue); DropDownList _newAnswerDDL = new DropDownList(); _newAnswerDDL = GetAnswerDropDown(_nextQuestionID); this.m_panel.Controls.Add(_ne

disable a single intem in dropdownlist or stop the ddl change event for a single item


hello guys,

I am trying something apart of my boundries, is there any way to disable a single intem in dropdownlist or stop the ddl change event for a single item.

any feadback would be appriciable.

Thanks and Regards

Inderjeet Singh Khalsa

Strange connection between ViewState and DropDownList's SelectedIndexChanged event


So, I have this code (just for example):

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <form id="form1" runat="server">
        <asp:Label ID="Label1" runat="server" Text="Sort by:"></asp:Label>
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" 
            <asp:ListItem Value="A" Text="A"></asp:ListItem>
            <asp:ListItem Value="B" Text="B"></asp:ListItem>
            <asp:ListItem Value="C" Text="C"></asp:ListItem>
            <asp:ListItem Value="D" Text="D"></asp:ListItem>
        <asp:GridView ID="GridView1" runat="server" onsorting="GridView1_Sorting">

The Code-behind file looks like that:

public partial class _Default : Syst

Fire a dropdownlist event?


 Hi, I want to fire an event and fill some data but no idea.Thanks for hints.

The web page code.

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="StateChart.aspx.cs" Inherits="StateChartList"  Title="Untitled Page" %>

<%@ Register Assembly="WebChart" Namespace="WebChart" TagPrefix="Web" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:DropDownList ID="ddState" runat="server" AutoPostBack="True" >
    <asp:ListItem Value="AL" Text="Alabama"></asp:ListItem>
<asp:ListItem Value="AK" Text="Alaska"></asp:ListItem>
<asp:ListItem Value="AZ" Text="Arizona"></asp:ListItem>
<asp:ListItem Value="AR" Text="Arkansas"></asp:ListItem>
<asp:ListItem Value="CA" Text="California"></asp:ListItem>
<asp:ListItem Value="CO" Text="Colorado"></asp:ListItem>
<asp:ListItem Value="CT" Text="Connecticut"></asp:ListItem>
<asp:ListItem Value="DE&qu

Onchange event for datetime field in javascript is not working?


I want to compare start date and end date when start date is changed. If start date is big, on change event i need to make the end date the same as start date.

So I wrote On change event for start date. But it doesnot work  

getField('input','Start Time').onchange = function() {showEndDate()};


function showEndDate()



var date1 = getField('input','Start Time');

var date2 = getField('input','End Time');


but its not firing at all. So you guys have any idea or any other way to do for datetime on change event?

Dropdownlist in a repeater firing the SelectedIndexChanged event


I have a dropdownlist in a repeater and it's firing the SelectedIndexChanged event but in teh event handler I can not get the dataitem associated with the row that the DDL is in.  Here is the code:

        private void pt_SelectedIndexChanged(object sender, EventArgs e)
            DropDownList ddl = (DropDownList)sender;
            RepeaterItem ri = (RepeaterItem)ddl.NamingContainer;
            int userdevi

dropdownlist item onmouseover event?


Hi friends,

my project needs for when i focus mouse pointer on items in dropdownlist display a some information in div related to focused item. 

Plz help me...

Need to Remove Event Log Error after deleting a database sharepoint 2010


I deleted a couple of databases  fron SQL after recreating  the service application. I am getting event log errors  ID 3760 that these db's are unable to be located.

How do I remove the trigger that is making this error apear?

I have looked all through CA but unable to figuer it out.

Calling a DropDownLIst's Selectedindexchange event on pageload


Good Morning,


I have an ASP.NET 2.0 that contains a dropdown list used to filter records based on a group number.  For example, if the dropdown list selectedvalue = 3, only records containing a 3 in the group number column of the table will display.  This is working perfectly.  However, when the page first displays the default value is 1, and the records from group 1 do NOT display unless I trigger the dropdown list event.  I am trying to get the records to display for group 1 when the page first opens to avoid having to use the dropdown when the page loads. 


The "drop down list control" filters records in a "data list" control.

Onchange event for textbox not fiiring inside updatepanel



i am developing the webpage using Visual 2008.In that i have  i am using update panel and displaying  values in the textbox bby using webservices from sql database.I need this thing if  textbox values changes i need to change the backkground color of the text box also, so that user can easily identify which textbox values are changing. like this i  have 5 more text boxes control in the same form .i have tried but i could not  able to get done. i have written javascript code on change event of the text box  it does work.if  u people have any suggestion  kindly inform me . i am using trigger  to update the content panel.for your references i have copied the code.

This is the code i have wrriten in timer tick event

 Protected Sub UpdateTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
        'TextBox1.Attributes.Add("OnChange", "check(this);")
        TextBox1.Attributes.Add("onfocus", "check(this);")
        Dim obj As New ex.wb_service

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.

DropDownList SelectedIndexChanged event not fired when programatically setting SelectedValue


In our asp.net web application we load the dropdown list boxes in the page load.  We than set the SelectedValue of each dropdown list box to an object from session.  We have event handlers for many of the SelectedIndexChanged events of the drop down lists boxes, but these do not get executed when we set the selected value programmatically.


Someone else mentioned this is by design, and only when a user manually changes the drop down list selected index, will the event get raised.


I would think this is a common scenario of wanting the selectedindexchanged event handled when setting the selectedvalue/selectedindex/listitem's selected property, of a DropDownList.  What is the suggested way to handle this?  Is there a significant drawback of creating a custom control inherited from DropDownList that has the functionality of raising this event when changing the SelectedIndex or SelectedValue?



Employee Training Export event and remove rich text editor

I have couple of problems with employee training template.

There is an export event on this template to your calendar. You can click on this button ( export event) and you can save this ics file on to your outlook calendar. Can I anyhow change the text of this "export event" text to something else. I went to sharepoint desinger and it doesnt even have export event listed there.. just dll.. and when I do view source on the page i see under HTML.. but How can i change this?


When someone is trying to add a new course we would like to users to not have capibility of changing fonts/ etc.. When you enter course desciption rich text editor gets enabled... on top. Is tehre a way to disable this for this template or specific sites?

Please help

Thank you

WebPart DropDownList Control SelectIndexChanged Event Issue



In the below SharePoint WebPart, when I select the DropDownList control the SelectIndexChanged event does not get fired. The page reloads!

Why is this?


using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;

using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using System.Web.UI.WebControls;
using System.Data;

namespace ActiveDirectoryWSP
  public class UnlockUser : Microsoft.SharePoint.WebPartPages.WebPart
    //control definitions
    protected DropDownList myList;
    //non control definitions
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