Visibility (ASP.NET)

Visibility (ASP.NET)

We’re halfway through the week !


One of the things I’m working on this week is the “Forgot Password” page for my website. Through this page, a user having trouble remembering their password would enter their username, enter the security questions they chose when their login was initially created(retrieved from database using SQLDataReader) and , if answered correctly, would be directed to enter & confirm their desired new password.

I make it an effort to implement things that I learn along the way when creating my pages or when I’m feeling wild (lol), I just play around with the settings in Visual Studio and see what they do. This led me to discover ways to use the Visible property on and off to my advantage. With each click event, it prompted the visibility of the textbox and label controls I needed to return true and the visibility of the ones i didn’t need to return false. I was especially excited to see that it works for entire <div> sections too, saving me a great amount of coding.

With the help of conditional statements, the things i wanted my “Forgot Password” page to do, which before would’ve taken me like three pages to do (“Enter Username” page, “Answer Security Questions” page, “New Password” page) only took me one page to accomplish, which is going to make my life so much easier and my website much smaller. I definitely plan on going back to other pages/parts of my website and using this method where applicable, deleting unnecessary pages, etc.

The last part I am working on on this page is the function to lock an account if the user answers the security questions incorrectly after a certain amount of times (probably 5), their account would be locked and the page would prompt the user to contact the administrator. So far, I’ve observed that what I’m looking to achieve works the best if I declare/initialize a counter outside of the click method and, within the click event and an “if” statement, increment the counter variable every time the user answers at least one of the security questions incorrectly. The only downside to this however is that once it reaches the number of times I set, it now displays the locked message for ALL users in the database, which is something I’m trying to find a workaround for. I’ll be sure to keep you all posted on the end result. In the meantime, be sure to like, comment, and/or subscribe to my blog and offer suggestions as you see fit.

Happy coding, everyone 🙂

Coding soundtrack of the week: Miguel(War & Leisure)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s