MVC Forms - Toggle Model Validation - c#

I have an MVC form which allows user to add some details about a "service" related to their account. My problem is that they can save and resume this form whenever they want so I don't need to check for required properties until they choose to "publish" this service.
My problem is I am not sure how to implement validation. I've looked here but I think I will need to use the same view because at any stage in the form they can choose to either "save and resume later" or "save and publish"(validation needed on this click).
I thought about maybe using a model without any required attributes up until the point where this "save and publish" button is clicked and on this click casting/converting the data from this model with no validation to the model with validation and checking validity but I am not sure if this is the correct way to go?
Any help/pointers appreciated.
Liam

Related

Action.Submit validation #bot frameworkV4

My bot consists of adaptive card which has text box and submit.action,when user clicks on submit it does some action in the next dialog
Iam able to prompt the adaptive card and submit the action .
But i need 2things to be done here
1.for few cards when user go back and resubmit the form it has to submit with old data
2.when user go back and click submit it has to throw some prompt message saying card expired or submitted already
I an working with .net core,v4 and waterfall dialog
Can anyone help me in this.
There isn't an easy way to do this in the current state of the Bot Framework. Here's a couple of good options:
Use the AdaptiveCardPrompt. This isn't officially-supported, but I believe provides you with all of the customization you're looking for, out-of-the-box.
Attach your Adaptive Card to an ActivityPrompt and write a custom validator for it.
The trickiest part about your issue is collecting data from a card after the user has already completed the prompt. Once the prompt is over, there's no good way to use it. However, you could:
Add a card Id to the data property of the Action.Submit
Capture the input in OnMessageAsync()
If Activity.Value contains the card Id from step 1, handle it appropriately. Note, however, that it gets very difficult to use this within a dialog if the prompt has already completed.
You can go through the following link for handling user action https://learn.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-dialog-actions?view=azure-bot-service-3.0

Allow (De)Activating only for users with specified field security profile

I'm looking for the best way to forbit (de)activating a record for users that do not have a specified field security profile.
My approach was to display/hide activate/deactivate button depending on the users profiles. And add a synchronous plug-in that checks security profiles when (de)activating a record.
Is there a simpler way? With this approach I have to edit 6 button commands (hompage grid, form, subgrid - activate and deactivate button) and I have to create a new plug-in.
It looks like you have covered all the bases. The most fail safe way would be with a plugin that runs pre operation and checks the security role. From a user point of view it would return an error which might scare them. By hiding the buttons you remove that problem but have to be careful to make sure you remove them from all places you can deactivate a record.
I would say to do both if you want to be sure.

Storing all the events that happened inside a Windows Forms application

Is there a way to store all the window form events inside a list, so all of those events can be reapplied when the user opens the form next time?
Example: Let's say the user clicks a button inside a form and types in a string and then closes the form. After a while the user reopens the application again, and the form is re-initialized so that the click action and the string the user input is restored. (Kind of like an auto-save function.)
Purpose for this:
Recover after suspension.
Allow user to undo their work (Undo Button).
I am still not sure I understand you, but you say you want to get a list of events, okay, that can be done using Reflection. Here is a good link: http://www.switchonthecode.com/tutorials/csharp-tutorial-using-reflection-to-get-object-information
Your example:
Let's say the user clicks a button inside a form and type in a string,
he then closes the form, after a while he open the application again,
and form can re-initialize the form and apply the click action and the
string he inputted(kind of like an auto-save function).
-You can do this without getting a list of events. So I don't see why you have to do it this way. There are multiple ways to do this. If you are using a winform, one basic solution is to define properties using the settings page. Check this out:
http://msdn.microsoft.com/en-us/library/cftf714c(VS.90).aspx
Use the Settings page of the Project Designer to specify a project's application settings. Application settings enable you to store and retrieve property settings and other information for your application dynamically. They also enable you to maintain custom application and user preferences on a client computer. For more information, see Application Settings.
To access the Settings page, select a project node in Solution
Explorer, and then, on the Project menu, click Properties. When the
Project Designer appears, click the Settings tab.
You can establish waypoints (to borrow a term from aviation) and save values to your settings collection periodically without the user having to do anything, like they would have to do if you provided a save button. But that just brings up the point, what's wrong will the lowly save button. It's a well known convention. People know that if they don't want to lose data, they should save every now and then.

jQuery UI Dialog Read-Only / Edit Form with ASP.NET MVC

I have a table of data. I would like the user to be able to select a row and view the details in a jquery modal dialog.
I have this working fine. Based on permissions, the user may be able to edit the data in the modal. In this case, I would like to present a button to switch to "edit" mode.
Would it make sense for this button to load a new partial Edit view into the modal? or should I just combine the Read-only and Edit forms into a single view thats loaded intially and use javascript/css to hide the Edit Form until needed?
I think it's more of a design question as long as you don't send the Edit Form to the client side and only hide in case when the user doesn't have the permission to edit it.
Otherwise you'll be better of discussing this with the stakeholders.
In my personal opinion, I simply hate Modals. They just tend to be very overwhelming but that's just me :)
Why would you waste network traffic by downloading both views together? I would use separate ajax call to download edit form.
1. If your edit form is large in html size, you would waste traffic when downloading together (User may never press the edit button)
2. If edit form is relatively small, switching to it via ajax downloading would be almost transparent to user - no extra timing, no extra traffic waste

how to validate a textbox programmatically, that is at run time

i am creating textboxes when a button is clicked and again and again and so on
while accepting input i need to check if the boxes are all full,
i know how to do this using design view but how to do this using coding
that is add and validation control to the textbox when it created before initializing/adding it to the page.?
validation should be not null..
So as for validating the user input I would stay away from the ASP.Net Control Validators as hardly anyone in industry uses them. I would use the jQuery validator plugin which is included in a new Visual Studio project by default. You will still want Server side checking but it is much easier to call String.isNullOrEmpty(txtBox.Text) rather than using the Control Validators.

Categories

Resources