?
Solved

enable button control with textbox textchanged event

Posted on 2013-12-03
4
Medium Priority
?
693 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

801 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