aspx TextBox not displaying html characters - asp.net

I have a web application which has a TextBox:
asp:TextBox runat="server" CssClass="form-control monospace" ID="SKEDescriptionTextBox" TextMode="MultiLine" Rows="10" Text='<%# Bind("SKEDescription")%>' />"
It is bound to a field SKEDescription which is derived from an old mainframe application and is simply text - with no formatting. (old green screen stuff)
Within the web app, the user can change this TextBox and the resultant text gets sent back to the mainframe - after a large amount of code to strip formatting and other characters which will upset the mainframe.
However, if the user enters any text which even looks like HTML (e.g. ) then the code fails even before it enters the checking code. This was solved by adding
ValidateRequestMode="Disabled"
to the TextBox asp: line.
So now the user can enter and it is successfully sent to the mainframe,
BUT when the screen is redisplayed all the new text is displayed EXCEPT - it is not there.
Is there another method/property of TextBox that controls what is displayed from the Bind source rather than the user input?
And as an aside this textbox I am typing into to describe the problem has exactly the same issue - I originally entered the code snippet at the top starting with the less than sign and the snippet was removed only the final /> was visible. Editing this box and removing the initial sign and the whole snippet appears by magic.!!!

As with this Stack Overflow page my page actually had two TextBox controls that occupied the same area of screen depending on whether the screen was in display mode or edit mode.
The snippet in the original post above showed the Edit TextBox. The Display control was
asp:Literal ID="litSKEDescription" runat="server" Text='<%# Bind("SKEDescription") %>' />
The addition of Mode= "Encode" to this snippet enables (apparent) html text to be displayed

Related

Avoid double clicking submit with validator display set to dynamic

I have some ASP.NET CustomValidators with Display="Dynamic". The layout of the page requires that I use them like this without a ValidationSummary.
<asp:CustomValidator ID="vldFirstThree" ControlToValidate="txtFirstThree" runat="server" OnServerValidate="ValidateTextBox" ValidateEmptyText="true" ErrorMessage="Please enter the first three characters of the owner name.<br />" CssClass="error" Display="Dynamic" Enabled="true"/>
If the user leaves the field blank and clicks submit, the error text is displayed. If the user fixes the problem and then clicks submit again, the validation error text clears, but a second click is required to submit the page. I've tried writing some server-side code and some JavaScript to cause the validated TextBox to blur() before submitting, but I'm still running into the need to click twice: once to clear the message and again to submit.
Is there a way to clear the error text and perform the submit with one click?
The answer is the second one here: RequiredFieldValidator have to click twice.
I had to set EnableClientScript="false".

TextBox of type Password is empty when printed in IE8

I have a form that has a textbox of type Password as a signature for the form. The user enters in their password to sign, thus the actual text should not be displayed but be dots. When printed, the textbox needs to still contain the dots to show that it has been signed. But when printed in IE 8 the box is blank. Firefox will print the dots but it needs to work in IE.
If it helps this is the basic textbox code.
<asp:TextBox ID="TextBox1" runat="server" textmode="Password"></asp:TextBox>
IE doesn't print <input type="password" /> for security reasons. That said, typing something in a textbox isn't "signing" a document in pretty much every jurisdiction (just saying...).
I suggest you use Javascript to detect if the password field has text entered and add a message to that page that says it's been entered?

ASP.Net PasswordStrength Control Display Issues in Chrome and Safari

First off, jQuery is not an option at this particular time in this project or I would just utilize that type of password strength option.
Currently I have an Ajax control toolkit control (PasswordStrength) setup to work with a textbox. The control is inside the table row/cell next to the textbox itself in which it validates. It is also setup to be a bar-type indicator that is displayed on the Right side of the textbox through the DisplayPosition property.
The strength meter appears fine in IE, Firefox and Opera ... Right next to the password field textbox and this is great. Now, in Chrome and Safari, the indicator appears at a random place on the page and if you continue typing the indicator actually moves up and down the page randomly, nowhere close to the right side of the password textbox. The indicator is technically correct on the x-axis, meaning it is "beside" the textbox, but the y-axis is sporadic and moves up and down the page, nowhere near the textbox. The behavior is the same in Chrome and Safari.
Any ideas? It's making me a bit nutty as I've tried wrapping divs, positioning, moving the control, adjusting properties etc.
Any help is greatly appreciated.
Here is the textbox and control itself as it is currently setup:
<asp:TextBox ID="txtPassword" Width="150px" runat="server"
Style="text-align: left" TextMode="Password" </asp:TextBox>
<asp:PasswordStrength ID="PS1"
runat="server"
TargetControlID="txtPassword"
DisplayPosition="RightSide"
StrengthIndicatorType="BarIndicator"
PreferredPasswordLength="16"
MinimumNumericCharacters="1"
MinimumSymbolCharacters="1"
MinimumLowerCaseCharacters="1"
MinimumUpperCaseCharacters="1"
RequiresUpperAndLowerCaseCharacters="false"
CalculationWeightings="50;15;15;20"
TextStrengthDescriptionStyles="barRed;barYellow;barBlue;barGreen"
Enabled="true"
BarBorderCssClass="barBorder"
BarIndicatorCssClass="barInternal">
</asp:PasswordStrength>
Any help or suggestions would be greatly appreciated!

I want to apply a regularexpressionvalidator to selective fields in DetailsView ASP.NET 2.0 VB

Hello, I have been having trouble with this for a while now. I have a bound textbox within a Detailsview, to which I have added a RegularExpressionValidator (REV). The Regular Expression used is [a-zA-Z]*
After running the Web Form, the Edit button opens the fields. Any entries made cause the REV error msg to be displayed when the Update button is pressed, irrespective of the validation. The Update button continues to be displayed until the Cancel button is selected and the original record is returned to the screen replacing any entries.
The RequiredFieldValidator works correctly.
Ray Brown
I would suggest you FilteredTextBoxExtender of Ajax Control Toolkit instead of using REV.
It gives you the option to validate the input for many types of validation for numeric, letter, or even custom types for example:
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<ajaxToolkit:FilteredTextBoxExtender ID="ftbe" runat="server"
TargetControlID="TextBox3"
FilterType="LowercaseLetters, UppercaseLetters" />

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