Solved

Selected Index Change of a Drop Down List

Posted on 2004-08-16
6
1,008 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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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 100 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

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