Click here to Skip to main content
11,488,212 members (79,807 online)
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 Sergey Alexandrovich Kryukov 489
1 OriginalGriff 353
2 Advay Pandya 155
3 Mehdi Gholam 145
4 Sascha Lefèvre 135
0 Sergey Alexandrovich Kryukov 9,308
1 OriginalGriff 8,352
2 Sascha Lefèvre 3,334
3 Maciej Los 2,956
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 28 Mar 2013
Copyright © CodeProject, 1999-2015
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