Solved

Selected Index Change of a Drop Down List

Posted on 2004-08-16
6
985 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
Comment Utility
u can do it with java script
0
 
LVL 8

Expert Comment

by:razo
Comment Utility
<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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 4

Expert Comment

by:hamood
Comment Utility
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 100 total points
Comment Utility
Check that the DropDownLists control has the option "AutoPostBack" is set to True.

regards,

KS
0
 
LVL 8

Expert Comment

by:daffodils
Comment Utility

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now