Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
hi,
i am asking a question please help me.
how can i change state of a button button_click to button_clicked.
i want exactly that if i hit submit button once then it moves to disable state and not work until i hit the cancel button or text changed in textbox.
i hope you understand the problem.
Thanx to all of you.
Posted 27-Mar-13 12:26pm
Comments
joshrduncan2012 at 27-Mar-13 17:28pm
   
Are you referring to buttons being enabled or disabled? You may want to look at the enabled api of button controls.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

The easy way is not to look at trying to change it to "clicked", but to disabled, or"greyed" instead.
That is easy: set the Button.Enabled property to "false" to disable it, and "true" to reenable it.
 
Handle the TextBox.TextChanged Event to reenable it.
  Permalink  
Comments
Vijay Pareek at 27-Mar-13 17:57pm
   
Thanx Dude...
Sergey Alexandrovich Kryukov at 27-Mar-13 18:51pm
   
Sure, a 5.
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Use WebControl.Enabled[^] property. All buttons properties are listed here: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button_properties.aspx[^]
 
Button1.Enable = (TextBox1.Text.Length>0);
 
[EDIT]
Windows.Controls.Button Class[^]
Windows.Controls.Button properties[^]
[/EDIT]
  Permalink  
v2
Comments
Vijay Pareek at 27-Mar-13 17:57pm
   
Thank You..
Maciej Los at 27-Mar-13 18:03pm
   
You're welcome ;)
By The Way, 3 stars means: fifty - fifty helpful.
Sergey Alexandrovich Kryukov at 27-Mar-13 18:51pm
   
It really means down-voting. :-( I voted 5 to compensate; correct answer.
—SA
Maciej Los at 28-Mar-13 2:38am
   
Thank you, Sergey ;)
Sergey Alexandrovich Kryukov at 27-Mar-13 19:22pm
   
Oh, why System.Web.UI.WebControls? The question says "Windows forms"...
Also, it makes sens in TextChanged event handler...
Whatever...
—SA
Maciej Los at 28-Mar-13 2:38am
   
Tag: ASP.NET :)
Sergey Alexandrovich Kryukov at 28-Mar-13 2:50am
   
OP deserves 1... :-)
Maciej Los at 28-Mar-13 3:38am
   
Answer updated, reference to Windows.Controls.Button added ;)
Sergey Alexandrovich Kryukov at 28-Mar-13 10:18am
   
Fair enough...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 562
1 Sergey Alexandrovich Kryukov 484
2 Maciej Los 325
3 DamithSL 233
4 Mathew Soji 195
0 OriginalGriff 7,168
1 Sergey Alexandrovich Kryukov 6,377
2 DamithSL 5,461
3 Manas Bhardwaj 4,876
4 Maciej Los 4,450


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 28 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100