Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Selected Index Change of a Drop Down List

Posted on 2004-08-16
6
Medium Priority
?
1,038 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
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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:
Ramesh Srinivas 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Screencast - Getting to Know the Pipeline
Suggested Courses

810 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