First few fields was like Username,Firstname etc. then it was Password field. Below that I was filling two combo boxes of City and State which was dependable on each other..So I was not having any choice but to post them back and fire SelectedIndex change event..All of the other information like Username,Firstname was in state and were able to retain their values which I key in them..but
don't know how..Password field was getting blank again and again.
One of my friend told me that this is because of Security reason,that we lost value in Password Textbox in Postback of page..Some people told me that its next to impossible to retain Password value in Postbacks and might be dangerous and against security policies.
But..I was not having choice as it was my task..so I tried out whole tons of experiment..All Sessions, Varibles,Constants,JavaScripts,HiddenFields,Enable ViewState..all stuff got simply failed..I was like no where..I then Google it..done few hits on Live engine and Yahoo..
Suddenly,I came across ViewState declarations on some forums..and It clicked.!!
I just wrote following piece of code and my 3 days research work got over finally..
ViewState["MyPassword"] = txtPassword.Text;
txtPassword.Attributes.Add("value",ViewState["MyPassword"].ToString());
and done with it..!!
Vikram.
0 comments:
Post a Comment