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.
Related
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
Hi everybody i have the next problem. I have to set a button as default when i press Enter. I can use DefaultButton in the Form because now all my pages inherits from Master Page and i have a Content from the Master Page and this isn't work. Somebody could give me any alternative to solve this please. Thanks
According to Enter Key - Default Submit Button:
ASP.NET 2.0 introduces a wonderful work around for this. By simply
specifying the "defaultbutton" property to the ID of the ,
whose event you want to fire, your job is done.
The defaultbutton property can be specified at the Form level in the
form tag as well as at panel level in the definition tag.
The form level setting is overridden when specified at the panel
level, for those controls that are inside the panel.
Also, the Event Handler for the specified button, fires thereby
simulating a true submit button functionality.
Like this
<form id="form1" runat="server" defaultbutton="Button1">
<div>
<asp:Button ID="Button1" runat="server" Text="Button1" OnClick="Button1_Click" />
</div>
Or you can achieve this by
Page.Form.DefaultButton = crtlLoginUserLogin.FindControl("LoginButton").UniqueID
or just
Page.Form.DefaultButton = LoginButton.UniqueID
This will work.
One way is through to recursively search through all your child pages controls and find the first button, get the id and set the default button of your form.
Although I have never tried this, I dont think its a very good idea as it is slow and error prone.
An alternative may be to do it through javascript/jquery, see this answer:
Submit form with Enter key without submit button?
I was just curious as to how the textbox + button search actually performs the search to fill up my gridviews, because I couldn't see anywhere that causes the databounds or anything. Is it a post-back thing? How does it work?! o.o
<asp:TextBox ID="SearchBox" runat="server"></asp:TextBox>
<input id="Submit1" type="submit" value="Search" />
Thanks heaps :)
There is no magic binding between a textbox called "searchbox" and a "submit" button in asp.net. The work has to be done somewhere and it's probably just hidden away in some part of the project that you cannot easily find.
In this case, it seems like a normal postback is occurring and some logic in the code behind is interrogating the "SearchBox"'s .Text property.
Just do a project wide search on SearchBox.Text, you should be able to find where the logic is.
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!
Drop Down list comes in front of all the controls. I have a calander extender for the text box which is right above(top) the drop down. when the calender pop's out it goes under i.e behind the drop down. Any solution friends.
How about posting some code/markup?
It wont like it via the google intellisense but you need to add the following to your DropDownList markup:
<asp:TextBox runat="server" id="TextBox1" autocomplete="off" />
By default if asp.net finds an attribute that it doesnt recognise then it simply passes it through into the underlying html that is generated.
Note 1: There is some kind of AutoComplete setting for this control but this doesnt do what you need it to do, you need the lowercase version like I have stated above.
Note 2: This is a non-standard attribute. It works in FF and IE but it will cause your validation to fail if you run it through the w3c checker.