Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Comments
joshrduncan2012 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.

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.
 
Share this answer
 
Comments
Vijay Pareek 27-Mar-13 17:57pm    
Thanx Dude...
Sergey Alexandrovich Kryukov 27-Mar-13 18:51pm    
Sure, a 5.
—SA
Use WebControl.Enabled[^] property. All buttons properties are listed here: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button_properties.aspx[^]

C#
Button1.Enable = (TextBox1.Text.Length>0);


[EDIT]
Windows.Controls.Button Class[^]
Windows.Controls.Button properties[^]
[/EDIT]
 
Share this answer
 
v2
Comments
Vijay Pareek 27-Mar-13 17:57pm    
Thank You..
Maciej Los 27-Mar-13 18:03pm    
You're welcome ;)
By The Way, 3 stars means: fifty - fifty helpful.
Sergey Alexandrovich Kryukov 27-Mar-13 18:51pm    
It really means down-voting. :-( I voted 5 to compensate; correct answer.
—SA
Maciej Los 28-Mar-13 2:38am    
Thank you, Sergey ;)
Sergey Alexandrovich Kryukov 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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900