?
Solved

Selected Index Change of a Drop Down List

Posted on 2004-08-16
6
Medium Priority
?
1,031 Views
Last Modified: 2008-03-04
Hello,
I have I one drop down list and one textbox contol on my asp page.
I want to do that, when I changed the selected index of a drop down list with special condition the textbox become disabled.
For example;
Private Sub ddlCalismaDurumu_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles       ddlCalismaDurumu.SelectedIndexChanged
        If ddlCalismaDurumu.SelectedIndex = 1 Then
            txtSure.Enabled = False
        End If
    End Sub
But this solution does not work. Because (I think) it requires refresh.
So how can I do that without refresh.
Many Thanks
0
Comment
Question by:emrahtufan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 8

Expert Comment

by:razo
ID: 11808843
u can do it with java script
0
 
LVL 8

Expert Comment

by:razo
ID: 11808857
<asp:DropDownList id="DropDownList1" runat="server" onChange="javascript:dropDownUpdate1();"></asp:DropDownList>

then add this function in the javascript section
function dropDownUpdate1() {
      if document.getElementById("dropdownlist1").value =1
document.getelementbyid("textbox1").enable=false;
}
0
 
LVL 8

Expert Comment

by:shovavnik
ID: 11808858
Can you use javascript for this solution or do you have to post back and disable the button on the server?

Does the solution have to be compatible for all browsers, or can it work just on IE?

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 4

Expert Comment

by:hamood
ID: 11808896
WHERE are you adding or binding date with dropdown list. if you binding data from any database then call the binding data like this in page onload event

if page.ispostback = false then
    loaddata()
endif

also set autopost back property of list box to true

i think your are not getting the selected index of of the list box. try to debug your code


Hamood

0
 
LVL 11

Accepted Solution

by:
saleek earned 400 total points
ID: 11809171
Check that the DropDownLists control has the option "AutoPostBack" is set to True.

regards,

KS
0
 
LVL 8

Expert Comment

by:daffodils
ID: 11810943

Check the "AutoPostBack" property for the DropDownList and set it to "True".
A selection change in a DropDownList does not cause a postback by default, that is why the SelectedIndexChanged event does not fire. A refresh sort-of simulates a postback and the event fires.

Set the "AutoPostBack=True" and you won't need to refresh.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month10 days, 15 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question