In this post I will explain how to maintain the password textbox text after postback. My previous post SQL Query to find Nth Highest or Lowest salary of an employee table.
Explanation
In Asp.net the password textbox will not remain the value after a postback happen, because the viewstate value will disappear. So for retaining the value in textbox control we have again reassign the value in viewstate.
Design
<asp:textbox onprerender="txtPassword_PreRender" id="txtPassword" text="abcd" maxlength="25" cssclass="TextBox" width="150px" runat="server" textmode="Password"></asp:textbox>
<asp:button onclick="btnSubmit_Click" id="btnSubmit" runat="server" text="Submit"/>
Code behind
In code behind textbox pre render event we have to assign the textbox value.
protected void txtPassword_PreRender(object sender, EventArgs e)
{
txtPassword.Attributes["value"] = txtPassword.Text;
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
}
Output
Note: By using the above code the password will show plain if view through page source code. My previous post SQL Query to find Nth Highest or Lowest salary of an employee table.
useful very much to me...
ReplyDeletePostBack is the name given to the process of submitting an ASP.NET page to the server for processing .
ReplyDeleteA simple example to illustrate the usage of PostBack is a login page. After the user has typed his username and password, he clicks on the ‘Login’ button. Upon the click, the page is sent to the server to check against the database/XML file to check if the user with supplied details is an authenticated user.
ReplyDeletepassword must be kept secret....
ReplyDeletePostback in an event that is triggered when a action is performed by a contol on a asp.net page.
ReplyDeleteJust do one thing after write down your Password do one thing take one hidden field in your form and Insert value on Postback (when you select combo box) after combo box coding executed again insert value from hidden value to Password field.
ReplyDeleteVery informative. Hope this technique will be used in an ethical way by developers and not misused in anyways.
ReplyDeleteIPostBackEventHandler serves to capture a client-side postback event (a click)
ReplyDeleteWorks - but now you have your password in the HTML source IN CLEAR TEXT ! Anyone can spy on that - not a very smart solution in my opinion .....
ReplyDeleteI'm truly enjoying the design and layout of your blog.
ReplyDeleteIt's a very easy on the eyes which makes it much more pleasant for me to come here
and visit more often. Did you hire out a developer to create your theme?
Outstanding work!
my page - clash of clans hack
constantly i used to read smaller content which as well clear
ReplyDeletetheir motive, and that is also happening with this post which
I am reading at this time.
Feel free to surf to my web blog; real racing 3 cheater (1rem.com)
Thanks all for your comments folks.Password must keep secret but the person who enter the password in textbox will only able to see through right click view source option.So no need to worry
ReplyDeleteNice explanation with snapshots, keep it up for more Dotnet online training
ReplyDeleteThe CCNA assertion shows an expertise in frameworks organization and consistent topologies. It exhibits that we can present, organize, and work LAN, WAN, and dial access organizations, including yet not compelled to the use of these traditions: IP, IGRP, Serial, Frame Relay, IP RIP, VLANs, RIP, Ethernet, and Access Lists.
ReplyDeleteRegards,
ccna Training in Chennai | ccna course in Chennai | ccna Training institute in Chennai
his article is very nice and easy to understand, it was a very weighty once thanks a lot admin can hopefully be improved in the future and pardon me permission to share the article here : Cara menyembuhkan gagal jantung
ReplyDeletewow...nice blog, very help full information. Thanks for sharing.
ReplyDeleteNO.1 SYSTEM INTEGRATION SERVICES | SYSTEM INTEGRATION MIDDLEWARE | MASSIL TECHNOLOGIES
Good information with great explanation. Thanks for sharing, keep updating.
ReplyDeleteNO.1 CLOUD SERVICES | Oracle Cloud PAAS | MASSIL TECHNOLOGIES