Solved

enable button control with textbox textchanged event

Posted on 2013-12-03
4
652 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

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 …
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.…

766 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