Default text appearing in the password text box ..how to make it disappear? - asp.net

Even though "Text" property is set to Text=""
asp:TextBox MaxLength="256" runat="server" ID="passwordTxt" TextMode="Password" Text=""
I also tried this on Page_load :-
passwordTxt.Text="";
I am still seeing 5 dots in the Password text box..How to make it go away ? Why is it there anyway ? like why ?
[EDIT]
I was not able to see Bold, Code tag buttons when posting this ques..so couldnt include my code lines inside of code tags..whats wrong with this website ??
[EDIT2]
ok I can see the buttons now

It's probably the browser auto-populating for you. View the source, it will be empty.

To stop firefox auto prompting to save this data in a form, add the following property to the form tag
autocomplete="off"
i.e. :
form id="myForm" runat="server" autocomplete="off"

Related

get checkbox text on same line as control using asp:CheckBox control

I have found numerous references to this but still cannot get it to work.
Several people have pointed to a previous post from 7 years ago that has a similar sounding problem but as detailed below the solution for that does not work at all.
I have the following asp code:
<asp:CheckBox id="checkbox1" runat="server" Style="display:inline;"
AutoPostBack="True" Text="Send Emails" TextAlign="Right"/>
It displays like this:
If I go into the elements explorer in Chrome I see the following:
If I manually add the style attribute to the input line like this (using the Chrome Elements right click menu), it works:
What am I doing wrong and how can I fix this?
Update: This is the "solution" I wound up doing:
<div >
<input id="checkbox1" type="checkbox" name="checkbox1" style="display: inline"/>
<label for="checkbox1">I would like to receive periodic email</label>
</div>
While this works it is obviously just avoiding the question entirely by switching to a HTML control vs ASP.
There could be a solution. As asp:CheckBox creating three controls and the ID is checkbox1 try the css for ID's
#checkbox1
{
display:inline !important;
}
This should work properly.

Auto Complete not working on IE for a asp.net textbox

I have a simple textbox where I am trying to make the Autocomplete enable.
Example:
Works fine on Chrome and not on IE.
I even changed the settings on IE and made the AutoComplete enabled over there. But still there is no change.
Here is the code for the textbox which is inside a div tag.
<asp:TextBox runat="server" ID="txtSender" CssClass="span8 input-large"
ClientIDMode="Static" MaxLength="255" AutoCompleteType="FirstName"/>
Can anyone please suggest what might be the reason behind it?
In Internet Options (Options -> Content -> AutoComplete) try to "Delete AutoComplete history".

Read Only TextBox Value Disappears on postback

I want to keep TextBox attribute Read Only in web form. But when I keep this Read Only , On PostBackits values get vanishes and I get empty text. How can I achieve the same functionality without loosing TextBox values.
You can achieve this by preventing user to enter values in the textbox, thus add following attributes to the textbox. It will maintain values even on postback also.
onkeypress="return false;"
Change it by removing the ReadOnly=”true” from the tag , we will add it in the code.
Now in the code add the following :
TextBox1.Attributes.Add(“readonly”, “readonly”);
You probably have it like this right now:
<asp:TextBox ID="MyTextBox" runat="server" Enabled="false" />
Just change this to:
<asp:TextBox ID="MyTextBox" runat="server" ReadOnly="true" />
And it will send its value over postback like all other form elements while still being read only.

Why does AjaxControlToolkit TabContainer render all custom control markup properties?

This is a strange one to explain but hope I make sense.
Our organisation has a library of custom controls that we use in our solutions. One example of these controls is a textbox combined with a set of validators which can be configured appropriately by its properties set in the markup.
I now have a problem when using this control in (which I beleive to have narrowed it down) a TabContainer.
If I wanted to use the following markup in the container:
<scc:TextBox ID="txtEmailAddr" runat="server" CssClass="input EmailAddress" EnforceEntry="EmailAddress"
ErrorMessage_RequiredFieldNotCompleted="" ErrorMessage_ShowExclamation="true"
MaxLength="150" ShowErrorMessageBelow="false" Label="Email Address " />
When I save or reload the .aspx markup it then renders the following markup for the same control:
<scc:TextBox ID="txtEmailAddr" runat="server" CssClass="input EmailAddress" EnforceEntry="EmailAddress"
ErrorMessage_RequiredFieldNotCompleted="" ErrorMessage_ShowExclamation="True"
MaxLength="150" ShowErrorMessageBelow="False" Label="Email Address "
ClientSidePreventInvalidChars="True" EnableClientScript="True"
EnfoceOnPaste="False" EnforceMaxLengthWithRXOnMultiline="True"
EnforceOnPaste="False" EnforceSpaceInPostcode="True"
ErrorMessage_InvalidFormat="Email Address : Please enter a valid email address"
ErrorMessage_NumericValueInvalidOrOutOfRange="Email Address requires a number to be entered in the range to ."
GuidanceText="" GuidanceText_RenderInMouseoverPanel="False"
JavascriptURL="~/Include/TextBoxMaximumLength.js" LabelBold="False"
LabelCSSClass="" MaxValue="9999999" MinValue="-9999999" Read_Only="False"
RememberAnswer="False" RenderInParagraphs="True"
RenderRequiredTextForRequiredFields="True" Required="True"
RequiredField_InitialValue="" Rows="0" ShowMaxLength="False" Text=""
TextBox_TabIndex="0" TextboxSkinID="" TextMode="SingleLine"
TooltipPopup_BodyText="" TooltipPopup_TooltipText="(guidance)"
ValidationGroup="" ValidationExpression="" />
This would not be a problem other than the properties that are now being rendered in the markup are overriding default functionality of the actual control. In this case the default Email Address regular expression is being ignored because the property 'ValidationExpression' is being set to an empty string!
Again I could place the default regex in that property, but I would just like to understand why the markup is behaving in this manner?
Thanks.
Get the code for the AjaxContolToolkit and step through it to see why all properties are rendered. You can adjust that code as you need and compile the dll and use that. From personal experience, that is the only way I have found use for the Toolkit because of behaviors like you describe.

Regular input in ASP.NET

Here's an example of a regular standard HTML input for my radiobuttonlist:
<label><input type="radio" name="rbRSelectionGroup" checked value="0" />None</label>
<asp:Repeater ID="rptRsOptions" runat="server">
<ItemTemplate>
<div>
<label><input type="radio" name="rbRSelectionGroup" value='<%# ((RItem)Container.DataItem).Id %>' /><%# ((RItem)Container.DataItem).Name %></label>
</div>
</ItemTemplate>
</asp:Repeater>
I removed some stuff for this thread, one being I put an r for some name that I do not want to expose here so just an fyi.
Now, I would assume that this would or should happen:
Page loads the first time, the None radio button is checked / defaulted
I go and select a different radiobutton in this radiobutton list
I do an F5 refresh in my browser
The None radio button is pre-selected again after it has come back from the refresh
but #4 is not happening. It's retaining the radiobutton that I selected in #2 and I don't know why. I mean in regular HTML it's stateless. So what could be holding this value? I want this to act like a normal input button.
I know the question of "why not use an ASP.NET control" will come up. Well there are 2 reasons:
The stupid radiobuttonlist bug that everyone knows about
I just want to brush up more on standard input tags
We are not moving to MVC so this is as close as I'll get and it's ok, because the rest of the team is on par with having mixed ASP.NET controls with standard HTML controls in our pages
Anyway my main question here is I'm surprised that it's retaining the change in selection after postback.
This is a Firefox behavior.
Firefox will persist form values when you reload a webpage.
For example, if you go to StackOverflow's Ask Question page, enter some text, and reload the page, Firefox will remember the text, but IE will not.
If you re-request the page (as opposed to refreshing it) by pressing Enter in the address bar, the form will not be persisted.

Resources