I have a ASP.Net Core MVC web application. I have a standard razor view which has a list of items with a delete button. What I want to do is if they user deletes an item from the grid go to the server calling an action which validates the item selected. IF invalid I want to return to the view and show a bootstrap modal explaining why the delete cannot be carried out. I call the delete routine using Controller / Action tag helpers and pass the unique Id to a controller event.
So basically if my delete validation fails show a modal dialog with a message. Any help please?
I ended up sorting this myself. Basically I set a viewbag property and give it a value of show. Then in my script section of my view I set the modal property to that viewbag.
Related
I am using Drupal 7.54. I want to attach or embed a node add form to a view so that when a user submits the form, the view below the form will be updated in realtime via ajax. The form will be shown above the view. My view block name is Statuses Stream.
I tried Form block module and putting the form in the header section of my view using views ui, but after submit, it was redirecting to the node created page.
Then I tried Advanced Form Block module. I created a form using AFB module. The form name is Statuses. It is submitting the form with ajax, but it is not updating the view in the realtime. I have to refresh the page manually to show the created node below the form.
I am open to any solution programmatically or through a module.
Note: For those who know, I am trying to mimic the statuses module. It does exactly what I am looking for. The problem began when I came to know that it is not an entity. So now I am trying to make the same functionality with Content type.
You could use something like Views Refresh to manually update the view below instead of refreshing the page.
I am fairly new to .NET and MVC3 - and even Ajax and Json, and am working on an MVC3 (razor) application, using jqGrid, and so far it is immense(jqgrid that is!) and has dealt with everything I have thrown at it.
However, I have One Outstanding peice of functionality that I do not know How to accomplish.
Within the Edit form of a Row, I have Placed a Custom button called 'Reset Password'. I need the Onclick Event to call a piece of functionality in my Controller to go through some logic, generate a Password, and Return the new Password to the Screen.
Can anyone tell me How can I achieve this?
May thanks in Advance.
You can return a partial view result or json data from the action.
See the partial view approach here
I am using ASP.NET 3.0 MVC with membership provider. I have to make modification to the default implementation we get with membership related code. I have to move LogOff Hyperlink in the master page. Initially this link is in-visible but once authentication is succesfful I need to make it visible. This action will happen from Controller for authentication and I am not sure how to access the hyperlink defined in a master page from a different controller. Any ideas how this could be achieved keeping the spirits of MVC design?
You could create another action in your AccountController to determine if the log off link needs to be displayed. This action has a partial for the html. Call this new action from the master page and check in that action if the log off link needs to be displayed.
#{ Html.RenderAction("displayLogOff", "Account"); }
I'm not sure why you need to make a modification, as this seems to be the default behaviour, but typically you would use a partial view to display the log off hyperlink. This partial view can run an action, and in this action you would send a model to the view which could include a flag for if the user is currently authenticated. Alternatively, you can just check Request.IsAuthenticated in the partial view directly.
I'm not sure I understand. The default implementation already does this. It works regardless of what controller you're using. The reason is that the master page uses a partial page that specifies the method and controller.
I have created an asp.net mvc 3 razor view and added data annotation attributes on model properties. when i click the submit button on form, I see the validation messages as I used Html.ValidationMessageFor. but I dont see validation summary although I have added #Html.ValidationSummary(true). Please suggestion fix.
Try passing false:
#Html.ValidationSummary(false)
How Can I Return or open a view in new window browser from only controller code when some validation a true But Not from Links and button code it should open automatically modelstate if is valid.
Thanks...
My guess at what you are trying to do is have the browser pop up a window once the form is correctly validated. The way I would do this is to have a javascript function that is validating the form and once it is valid then pop up the new window.
If you want the validation to occur on the server side you could use AJAX to post the current form values back to the server and have it return the validation.