Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Derik Whittaker

Thoughts on Software Development, .Net, OOP, Design Patterns and all things cool



TextBoxes and Password Chars -- Strange behavior

So, today I needed to create a 'password' entry text box for my application at work. I needed to have this perform like every other password text box, but I also needed the text box to be MUCH larger than normal (the application is for Tablet PC and everything is over sized).

I set the UseSystemPasswordChar to true and ran the application and BAM... nothing happened. OK, so I set the PasswordChar to '*' and set UseSystemPasswordChar to false and re-ran the application and BAM.... nothing happened again.

Now I am stumped. So I go out to MSDN to make sure I am doing this correctly and sure enough it appears I am.

After looking at ALL the properties for the control for a good 5 minutes I realized that I had set the MultiLine property to true. Just for fun I set it back to false and re-ran the application and BAM... it now works.

OK, can anyone tell me WHY setting the MultiLine property to true will NOT allow either the PasswordChar or UseSystemPasswordChar to work correctly? I went out the MSDN again, but could not find any reference to MultiLine anywhere on these topics.

Is it just me or is this odd?



Comments

Eber Irigoyen said:

never seen a multi-line password

on the web controls the modes are

MultiLine

SingleLine

Password

http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.textboxmode.aspx

# October 25, 2006 11:17 AM

Zach Parrish said:

When you set the MultiLine property to true, it changes the way the textbox is rendered in html.  Instead of being an input element with a type="text" attribute (or password in your case), it becomes a textarea element and so it loses the password functionality.

# October 26, 2006 9:29 AM

Zach Parrish said:

I just noticed this was in regards to WinForms, sorry about the previous comment...I'm just always in web developer mode.  So I'm not sure why it wouldn't work then.  Maybe MS was just trying to keep control behavior consistent across winforms and webforms? Or perhaps they decided for you that there would surely be no case in which you would ever need a multiline password input box.

# October 26, 2006 9:35 AM

Fritz said:

I'm just guessing, but it probably renders the HTML for multi-line as something like:

<textarea name="textareaName" rows="4" cols="40"></textarea>

instead of:

<input type="password" name="pwfieldName" size="24">

in which case, you'd have to use javascript to trap keydown events for the textarea in order to populate some off-screen variable while dumping "*"s into the textfield.

Cheers,

Fritz

# October 29, 2006 8:48 PM

Jon Ronnenberg said:

No se.

But it strikes me that no one would ever use a multi lined textbox for passwords so why should Microsoft add support for it?

# October 29, 2006 8:56 PM

PartialClass said:

why u need a multiline textbox for password ?

Are you going to write story in it? :D

# November 17, 2006 12:50 PM

Derik Whittaker said:

I dont really need to, but i was just noticed that it really screwed stuff up.

# November 17, 2006 7:22 PM

Adi said:

The ES_PASSWORD is valid only for single-line edit controls. So ES_MULTILINE and ES_PASSWORD won't work together.

# November 19, 2006 2:20 PM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Derik Whittaker

Derik is a .Net Developer/Architect specializing in WinForms working out the northern suburbs of Chicago. He is also believer and advocate for Agile development including SCRUM, TDD, CI, etc.

When Derik is not writing code he can be found spending time with his wife and young son, climbing on his bouldering wall, watching sports (mostly baseball), and generally vegging out. Check out Devlicio.us!

Our Sponsors

Proudly Partnered With


This Blog

Syndication

News