MVC3 - How to remote validate on checkbox click? - asp.net-mvc-3

I am using the Remote Validation attribute on my domain model, to call an Action that returns Json. This validation occurs on a checkbox and it only kicks in when the form is submitted. I'd like it to act the same way that text boxes remote validation works. As soon as it looses focus, remote validation kick in. Or perhaps on click.
These are screen shots from a test project. The actual project is too busy, that's why I created this sample one.
I'd love to see some suggestions that do not involve using JQUERY in the view. But if that's the only way then be it.
Thank you.
MODEL:
Both properties have the same Remote validation, because I wanted to test if the loosing of focus would trigger the text box to validate, and indeed, it worked. I assumed that the same would happen for the check box, perhaps on click, or loosing focus, but no. Only when I click create the IsNameDuplicate() is called.
CONTROLLER:
VIEW:

Related

Change Sidedrawer content dynamically

I´m at that point on my app, where the user Logged in, receive the data from the server and now i need to make same changes. One of the changes is change the button that appears on my Sidedrawer saying Log In to Log Out and vice-versa when the user Logs Out...I could talk about other changes but i think the main thing is...
How do I access the Sidedrawer content in order to change/add buttons. I already entered the app-root.xml and made same testing adding the navigatingTo="onNavigatingTo" function and also in the .js file just to see if it responds, but it doesn´t...
How do i perform this?
You can show/hide your button via visibility, text binding or via a structural directive like *ngIf (if using Angular). For example, take a look here - I am showing/hiding a button based on whether the user is logged in or not (here is the related code-behind code).
The above example is using an Angular directive and can be applied only in Angular based applications, but with the same logic, you can substitute ****ngIf*** with visibility and achieve the same in TypeScript or plain JavaScript app.
The easiest way to do it is put the frame inside drawer content area, then navigate frame to another page.

NSIS - InstallOptions - Skip validation on back button

I am developing an NSIS package for one the products. I have a custom page for gathering SQL Server login credentials. On this page, clicking next must validate the given inputs (whether it connects to the server with given credentials). This works fine.
Problem:
If I press back button on this page, it is still validating the input; which I do not want. I could not find any way out to skip the validation on clicking back button.
Any suggestions in this regard is appreciated.
Found the answer!
We can specify two function names while calling the page custom command. One to show the page and one for validating which is called as leave page.
Page custom ShowDatabasePage LeaveDatabasePage
In the leave function, we can do all the validation. If the validation fails just call abort and the work is done. Leave function is called only when the next button is clicked.

Lotus Web Form Scroll and Popup issue

I am trying to create a web form in Lotus Notes that is web enabled. So far this has all worked fine, however there are 2 issues.
When Creating a Java Script Alert in the OnLoad Event, it Pops up everytime a user selects a radio button or dropdown option since this reloads the page. Is there any way to make this only for the initial opening of the form?
When a user selects an option, the form reloads and puts that form field on the top which is proving to be very disorrienting for users. Is there a way to have it not scroll on reload?
Thanks in advance!
The best advice would be: use XPages for web development that is "state of the art". If you can't, you have to code a lot of JavaScript to make the form not behave like "havoc".
First of all: the field property "refresh fields on keyword change" is the reason for the jumping / reload.
What does domino do?
All events / formulas that occur when you normally press F9 or use the Option above (that can be field values, input translations, hide whens, etc.) are not "converted" to HTML and javascript but are executed by the server. Therefor each change in a field with the option set submits the form and adds an &Seq=x to the url to keep track of the state. X increments on every reload. Of course this reload causes all events to be triggered again.
For you this means:
Option
disable the option to reload the form after keyword change.
Unfortunately you have to recode every dependency / calculation / hide when with javascript. Using a framework like jquery or dojo this is possible, but a lot of work.
If there IS no dependency then just disable the option...
Option
Live with the "jumping" and let your onload event check for the existance of an URL- parameter called seq... And only if it does not exist, then it is a "real" OnLoad...
Both options are not quite nice and not very easy to code...
That's one reason why IBM started XPages... There all this stuff is already handled by default...

MVC 3 Client Side Validation Catches Some ValidationAttributes but not others?

I'm confused by this behavior:
I have an out-of-the-box MVC3 app. I haven't really done any customization from the what the scaffolding template gives me.
In web.config, clientsidevalidationenabled and unobtrusivevalidation are both true.
I have a class with one field using the Required annotation, one using StringLength and one using RegularExpression. When I'm editing an object, the textboxes for the properties marked with StringLength & Regex report problems instantly in the UI, but the textbox for the Required doesn't.
If I hit SAVE, then "Model.IsValid" is the controller sess the problem with the missing Required and I get the UI error message next to the text box.
If I view the source of the page, I can see that the markup for the required property does have the dataval-req and other related attributes generated by the Unobtrusive validation.
Is this expected behavior? If it is, what's the reason? If it's not, what might I be doing wrong?
Thanks! :)
As long as the page is not posting back to the server, this should be the correct behavior. The required client-validation will fire only if:
You don't enter data and try to post to the server.
You enter data in the text box and then remove it.
Otherwise the user would be inundated with error messages.
I've gotten to the bottom of this behavior, just by banging on the keyboard some more. It's as expected. In the Create view, the behavior is as #Beavis describes. In the edit view, unobtrusive validation prevents the required property from being validated on tabbing BEFORE the first attempt at hitting SAVE. SAVE then does a UI validation (no postback occurs) and shows the error message next to the property. Once I've hit save that first time, that property responds to tabbing. So now if I make it valid, the message disappears on tab. If I erase the contents of the text box, the message reappears on tab.
Thanks for everyone's help.

Sending postback to ajax loaded user controls

I have a set of tabs, which all of them together contain alot of data. I am making the tabs load async. I have one button above the tabs used to save changes. I need this button to send a postback to all the loaded user controls (using this). I need the user control to handle this postback so it can save changes.
What do you think? Any suggestions?
Tried doing it, doesn't work. I am going to have to do some magic with updatepanels and a custom postback.

Resources