I am using asp.net codebehind (c#) and I wrote code for checking the username and password.

I want the other parts of the form to be inactive or "grayed out" so the user can't edit them until they successfully enter in the correct username and password. I would show code but it really doesn't relate, but if you want to see what I have I will put that in here too!

Can someone help me with this!

Thanks!

Recommended Answers

All 3 Replies

Most form controls have an 'enabled' property that you can set to false until the user is logged in as which time to switch them all to true. Buttons will be greyed out, text areas can't be clicked inside, etc.

Most form controls have an 'enabled' property that you can set to false until the user is logged in as which time to switch them all to true. Buttons will be greyed out, text areas can't be clicked inside, etc.

That is exactly what I was talking about! I know I was being confusing.

Do I need to write an if statement to go with that when I enabled it to false?

Depends how you set up your code. You will obviously have a check at some point to ensure the user is correctly logged in so at that point you simply roll through the controls altering their enabled status to true.
I guess you could set up a function that toggles the state of the controls then you call the same function to disable or enable them and that would require an if statement. But this is probably not very relevant as I imagine the controls are disabled at page load and set to enabled after login and thats it, no more altering required.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.