Click here to Skip to main content
12,077,753 members (49,039 online)
Rate this:
 
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 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 27-Mar-13 17:57pm
   
Thanx Dude...
Sergey Alexandrovich Kryukov 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 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
Maciej Los 28-Mar-13 2:38am
   
Tag: ASP.NET :)
   
OP deserves 1... :-)
Maciej Los 28-Mar-13 3:38am
   
Answer updated, reference to Windows.Controls.Button added ;)
Sergey Alexandrovich Kryukov 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web04 | 2.8.160212.1 | Last Updated 28 Mar 2013
Copyright © CodeProject, 1999-2016
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