Solved

enable button control with textbox textchanged event

Posted on 2013-12-03
4
644 Views
Last Modified: 2013-12-04
Below is code for trying to change a button control for button.enabled = true and false depending on condition.  I am trying to changed the enabled state of the button control when the text in a separate text box changes.  When called the code fires but nothing happens on the page.

Can anyone help?

Thanks,

Protected Sub DataEntry1_TextChanged(sender As Object, e As EventArgs) Handles DataEntry1.TextChanged

        If Not IsNumeric(DataEntry1.Text) Then
            EnterDataBtn.Enabled = False
            ViewState("BtnEnabled") = False
        Else
            EnterDataBtn.Enabled = True
            ViewState("BtnEnabled") = True
        End If

    End Sub
0
Comment
Question by:rckrch
4 Comments
 
LVL 11

Accepted Solution

by:
MajorBigDeal earned 167 total points
ID: 39694222
Try removing the ViewState lines. I just tried it and the button was disabled fine without them.  Also, try removing the numeric check just to see if you are able to disable the button on the text changed event (which worked fine for me).  If so, then the problem is probably that you are taking the other branch of the if-then-else statement then the one you expect.
0
 
LVL 27

Assisted Solution

by:Chinmay Patel
Chinmay Patel earned 167 total points
ID: 39694612
Also this will cause a PostBack I suggest you either take it to client side or use AJAX. What are you trying to achieve? if it needs to be server side validation I will strongly suggest to use AJAX so that user doesn't see a Postback.
0
 
LVL 11

Assisted Solution

by:SAMIR BHOGAYTA
SAMIR BHOGAYTA earned 166 total points
ID: 39694630
hi..

Try with Postback property of a textbox equal to true. It's working.
0
 
LVL 16

Expert Comment

by:Kamal Khaleefa
ID: 39694754
in the aspx page set the property AutoPostBack=true
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

816 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

11 Experts available now in Live!

Get 1:1 Help Now