Click here to Skip to main content
15,918,742 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
how to make switch case in which i have to make password field false.
i have bit column which if bit is 1 then password field must hide otherwise it will me visible
how i will do that??
Posted
Comments
JoCodes 22-Jan-14 4:26am    
What you tried ?
fak_farrukh 22-Jan-14 4:28am    
how use it cant understand that
Rahul VB 22-Jan-14 5:10am    
hello brother,

Let me split your question so that we understand and eventually meet your demand:
Firstly : You want to create a switch case in which you want to make a password field false.

Secondly:
"i have bit column" can you please elaborate this?

Already you got multiple solutions posted.

Now just for your quick learning

http://csharp.net-informations.com/statements/csharp-switch-case.htm[^]
 
Share this answer
 
v2
Comments
Rahul VB 22-Jan-14 7:18am    
+5 for valuable information
JoCodes 22-Jan-14 14:41pm    
Thanks rahul
Its no use of using Switch case,if you r having only one condition..

try this
C#
bool bit = false; // bit value from sql will be converted to bool
                txtPassword.Visible = bit;


anyhow your switch case here.
C#
switch (bit)
               {
                   case true:
                       txtPassword.Visible = true;
                       break;
                   case false:
                       txtPassword.Visible = true;
                       break;
                   default:
                       break;

               }
 
Share this answer
 
Comments
Rahul VB 22-Jan-14 5:14am    
short and sweet
Karthik_Mahalingam 22-Jan-14 5:24am    
Thanks Rahul
take one check box n make it enabled = false, autopostback=true,

add its event, click on checkbox go to events, double click Checked. it will generate event code at backend of the page.

in this event, add this code.

if(checkbox.checked)
{
 txtpwd.enabled = true;
}
else 
{
txtpwd.enabled = false;
}


plz let know if its works,
 
Share this answer
 
v2
Comments
fak_farrukh 22-Jan-14 4:41am    
where i have to write this code i want to detect automatically not using checked box
abdul subhan mohammed 22-Jan-14 4:49am    
if you want to use on member's id, n if u r using session to store member id then,
in pageload(), add if(!ispostback){ if(session["mem"] == 1){ txtpwd.enabled=true; } else{
txtpwd.enabled = false;} }
fak_farrukh 22-Jan-14 5:20am    
on pageload i want it false and when i checked the checked box then it become true..
for now i will use checkbox..
switch(condition)
{
 case 1:
  user define work;
  break;
 case 2:
  user define work;
  break;
 case 3:
  user define work;  
  break;
 case 4:
  user define work;
  break;
 default:
  user define work;
  break;
}


in condition should be output comes as 1,2,3,4....I am giving you example below

for(int i=1;i<6;i++)
{
switch(i)
{
 case 1:
  print "i is "+i;
  break;
 case 2:
  print "i is "+i;
  break;
 case 3:
  print "i is "+i;
  break;
 case 4:
  print "i is "+i;
  break;
 default:
  print "i is "+i;
  break;
}
}
 
Share this answer
 
v2
Comments
JoCodes 22-Jan-14 5:01am    
Use code tag for posting your codes , it makes formatted and Highlighted.

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