I have a form that I need the user to be able to type something in a textbox, after they tab out have them enter the same value in another textbox in proximity to it to assure they entered it incorrectly. After that, the second textbox is to disappear and they will continue to the next field without ever having a postback.
Does anyone have any recommendations on how to do this most efficiently? Is there a control that will facilitate this for me?
You can do it by javascript easily. on the onblur or onchange clientside events you should check two textbox's values.
An alternative option : maybe you want to use CompareValidator to compare values of your form elements. Don't forget to set EnableClientScript=true and use ValidationSummary control.
Related
I have a textbox and a listbox. The listbox is filled by a sqldatasource and I want to be able to filter out the listbox based on what's typed in the textbox. The filtering/searching works but ONLY once the textbox loses focus.
What I need is the listbox to filter/search WHILE I am typing and not require the textbox to lost focus.
If you are doing this yourself, i.e. no third party tools, you need to catch the textchanged event and update the source yourself based on what's typed. It's probably better if you use 3rd party tool or do this via javascript or at least ajax call to have better user experience.
I hope you have focus at the end of the character because abstractly speaking, there is no way to find out automatically when user will stop typing, so everything goes during typing.
Are trying to do this this with Jquery? or Ajax?
How do I check whether the controls in a usercontrol contain any value?
I have created a usercontrol called ctlCustomerAddress and I want to create an address record in the database if only I have the values in the textboxes.
There are number of ways to validate user input. You may use Validation Control (RequiredField), or write JavaScript code or write server side code to validate the user input.
You can use validation controls. Also write the save to DB code to a button inside the user control rather then the parent page ?
Is a RequiredValidator control what you're looking for? MSDN Reference.
You can also use CustomerValidator and RegularExpressionValidator controls.
Set their ValidationGroup properties to be the same as your submit button.
I would like to like to trigger a postback after user selects a date. Am using the AjaxControlToolkit's CalendarExtender control. The date textbox which is associated to the extender is editable too which enables the user to manually enter the date in a particular format. Values of quite a few controls which reside on that page are to be updated depending on the newly selected date and hence going to the server is a must.
I did try using the OnClientDateSelectionChanged property of the extender which lets me hook in my custom javascript, using which i was planning to trigger a postback but for some odd reason the function gets called only if the date is selected using an extender and not when manually edited (Hoping that it doesn't catch the click event over textbox's change).
Am sure many have tackled this issue before. Please do share. Thanks.
Here it is, Keep It Simple as they say. Set AutoPostBack of the text box to true and capture the OnTextChanged event on the server side.
I have an asp:textbox. On textchange of this textbox, I'm doing validation for the text entered. If the text entered is incorrect, I want to flash a message of incorrect text entered. Please re-enter. How can I do this in ASP?
Just use a RegularExpressionValidator and keep client validation property at it's default "true" value. The control will handle this behavior for you.
Here's an example in action with the code: http://www.w3schools.com/ASPNET/showasp.asp?filename=demo_regularexpvalidator
You should avoid using that property if you can. Your validation code will only run when you postback to the server, and you don't want to do a full postback every time the text changes unless you really have to. Instead, use javascript to handle the onchange event of the input element rendered in the raw html by asp.net. Then remember to duplicate your validation code on the server.
I have a GridView that lists a bunch of items and one of the columns has a link that displays a modal (AjaxToolkit ModalPopupExtender). Let's call that link "Show". In that modal, I have a asp:button for saving the data entered in that modal. Let's call that button "Save"
So when the user clicks on a "Show" link in a certain row, I'd like write some javascript that sets something in the "Save" button, so that in my code-behind, I can handle "Save".Command and use the CommandEventArgs parameter to get the value.
Is this possible, or do I just need to use a hidden input tag and set its value?
Not a direct answer to your question, but another possible way of solving the problem:
Place a HiddenField control on the page. In your code-behind, before displaying the modal popup, set the value of that control to the ID of the row that was clicked (or the row number, or some identifying value). Then in the code-behind of your Save button, you can just read the value of the HiddenField.
Well, after continuing the research, it looks like it cannot be done. The CommandArgument property might reside in the ViewState, but for this case, it is completely server side and cannot be changed using javascript.
If you are using Updatepanel, you need to place the Hiddenfield inside the Updatepanel. Otherwise you will not be able to get/set the value stored in hiddenfield.