thevan
thevan

Reputation: 10344

Clear Password TextBox in C#.Net

In the Update Mode, I have retrieved the Entered Password like below:

    txtConfirmPassword.Attributes["value"] = DR["Password"].ToString();

But in the Add Mode, I want to clear this TextBox "txtConfirmPassword". I have given like below:

    txtConfirmPassword.Text = "";

But it is not clearing. How to clear this TextBox?

Upvotes: 1

Views: 6266

Answers (3)

Stav Bodik
Stav Bodik

Reputation: 2134

Everything must be so hard with this asp.net try'd to set off/disabled for autocomplete , try'd to change text,try'd to change value attribute ,try'd to format my PC. . . only like this its works :

 <asp:TextBox Text="" oninput="this.type='password'" autocomplete="Off" style="border-color:black" CausesValidation="true" runat="server" ID="Password" CssClass="form-control" />

Upvotes: 0

redpois0n
redpois0n

Reputation: 131

txtConfirmPassword.Clear();

Isnt that working?

Upvotes: 0

Muhammad Akhtar
Muhammad Akhtar

Reputation: 52241

You can clear the value in the same way.

txtConfirmPassword.Attributes["value"] = "";

Reason: When you set the TextMode="Password", You will not be able to set the .Text property. In your case you are trying to set txtConfirmPassword.Text = "";, It will not have an any effect on Textbox.

Upvotes: 5

Related Questions