943,769 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 1160
  • ASP.NET RSS
Jul 31st, 2007
0

Urgent please

Expand Post »
Hi to all
I have an drop down list, in that there are two fields one is income, expenses and text box . If i select income from the dropdown list then the text box should be disabled, if i select expenses then the textbox should be enabled.

I have tried using this code.
My code
Protected Sub type_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles type.SelectedIndexChanged
If type.SelectedValue.ToString = "Income" Then
vc.Enabled = False
Else
vc.Enabled = True
End If
End Sub
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
usershan is offline Offline
4 posts
since May 2007
Jul 31st, 2007
0

Re: Urgent please

you should enable autopostback for the dropdown list otherwise it wont work.
If you need to run it on a client side then use javascript.

Thank you
Khaled
Reputation Points: 10
Solved Threads: 0
Newbie Poster
atal is offline Offline
24 posts
since Jul 2007
Jul 31st, 2007
0

Re: Urgent please

I'd also point out that in your code you have both code paths setting the control to Enabled rather than one changing it to Disabled. Possibly a typo in your post, possibly in your actual code, so I thought I'd mention it.
Reputation Points: 683
Solved Threads: 53
Posting Virtuoso
Infarction is offline Offline
1,580 posts
since May 2006
Aug 1st, 2007
0

Re: Urgent please

Click to Expand / Collapse  Quote originally posted by usershan ...
Hi to all
I have an drop down list, in that there are two fields one is income, expenses and text box . If i select income from the dropdown list then the text box should be disabled, if i select expenses then the textbox should be enabled.

I have tried using this code.
My code
Protected Sub type_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles type.SelectedIndexChanged
If type.SelectedValue.ToString = "Income" Then
vc.Enabled = False
Else
vc.Enabled = True
End If
End Sub
Try this

ASP.NET Syntax (Toggle Plain Text)
  1. Protected Sub type_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles type.SelectedIndexChanged
  2. If type.Text = "Income" Then
  3. vc.Enabled = False
  4. Else
  5. vc.Enabled = True
  6. End If
  7. End Sub
Reputation Points: 20
Solved Threads: 0
Newbie Poster
vbLegend is offline Offline
2 posts
since Jul 2007
Aug 1st, 2007
0

Re: Urgent please

Click to Expand / Collapse  Quote originally posted by vbLegend ...
Try this

ASP.NET Syntax (Toggle Plain Text)
  1. Protected Sub type_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles type.SelectedIndexChanged
  2. If type.Text = "Income" Then
  3. vc.Enabled = False
  4. Else
  5. vc.Enabled = True
  6. End If
  7. End Sub
No, the code he has written is perfectly right, and the event he is firing is a server side event which will work after page being processed to the server, thats why Autopostback is needed for combobox.

Khaled
Reputation Points: 10
Solved Threads: 0
Newbie Poster
atal is offline Offline
24 posts
since Jul 2007
Aug 1st, 2007
0

Re: Urgent please

>>thats why Autopostback is needed for combobox.

I thought it was drop down list.
Reputation Points: 347
Solved Threads: 13
Practically a Posting Shark
arjunsasidharan is offline Offline
812 posts
since Aug 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Deployement of web application Issue
Next Thread in ASP.NET Forum Timeline: asp.net mail merge ?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC