Derik Whittaker

Syndication

News


Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
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?


Posted 10-25-2006 6:29 AM by Derik Whittaker
Filed under: , ,

[Advertisement]

Comments

Eber Irigoyen wrote re: TextBoxes and Password Chars -- Strange behavior
on 10-25-2006 11:17 AM

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

Zach Parrish wrote re: TextBoxes and Password Chars -- Strange behavior
on 10-26-2006 9:29 AM

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.

Zach Parrish wrote re: TextBoxes and Password Chars -- Strange behavior
on 10-26-2006 9:35 AM

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.

Fritz wrote re: TextBoxes and Password Chars -- Strange behavior
on 10-29-2006 8:48 PM

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

Jon Ronnenberg wrote re: TextBoxes and Password Chars -- Strange behavior
on 10-29-2006 8:56 PM

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?

PartialClass wrote re: TextBoxes and Password Chars -- Strange behavior
on 11-17-2006 12:50 PM

why u need a multiline textbox for password ?

Are you going to write story in it? :D

Derik Whittaker wrote re: TextBoxes and Password Chars -- Strange behavior
on 11-17-2006 7:22 PM

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

Adi wrote re: TextBoxes and Password Chars -- Strange behavior
on 11-19-2006 2:20 PM

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

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)