Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

enable button control with textbox textchanged event

Posted on 2013-12-03
4
Medium Priority
?
710 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 11

Accepted Solution

by:
MajorBigDeal earned 668 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 668 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 664 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

636 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