Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how can i use boolean value in the textbox of asp.net webpage.
Posted
Comments
Sandeep Mewara 19-Jul-12 5:50am    
Not clear!
bbirajdar 19-Jul-12 5:53am    
Your design is wrong.. You should use a radiobutton or a checkbox....
StianSandberg 19-Jul-12 6:48am    
I give your comment a 5! :)
bbirajdar 19-Jul-12 7:52am    
:) Thank you AlluvialDeposit !!!
StianSandberg 19-Jul-12 8:26am    
even if I disagree that radiobutton is suitable for true/false scenario..

1 solution

Hi,

you can have '0' or '1' in the textbox. if you convert value '0' to boolean, it gives 'false' and converting 1 to boolean will give 'true'.
C#
bool result = Convert.ToBoolean(txtbox1.Text.Trim());
 
Share this answer
 
v2
Comments
StianSandberg 19-Jul-12 6:47am    
and if you convert string 'true' to bool you will get true.. magically :)

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