I am trying to show some PartialViews in bootstrap v.5 Modal. It's done by Ajax:
$("#modalDetails").html(result);
$('#staticBackdrop').modal('show');
But, how can I have PartialViews ViewData to get some specific data to show in Modal or do another action.
thank you all
Related
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.
I am new to jQuery mobiles. The radio button widget is properly rendering if I hard code that in a HTML file but the widget is not loading for the same HTML contents which I dynamically created from JavaScript via Ajax.
when i try checkboxradio( "refresh" ), I am getting an error like
"cannot call methods on checkboxradio prior to initialization; attempted to call method 'refresh'"
Any suggestion on how should I refresh the dynamic contents to get the JQM widgets?
Enhance the markup of Checkbox and Radio buttons dynamically using both .checkboxradio() and .trigger('create').
$('input[type=radio]').checkboxradio().trigger('create');
I am new to web development..
i have created views using Entity Framework in MVC3 Razor..
What i have done yet is,
i 1st created model(Clients) and DbContext(ClientDbContext) Classes.
then, i add controller with scaffolfind options
Template: Controller with read/Write actions and View, Using Entity Framework
Model Class: Clients
Data Context Class : ClientDbContext
Views : Razor(CSHTML)
It Creates the controller class and index, Detail, Delete, Delete Views...
After that i modified the index page for search and pagination...
All are working good...
in the index page i have create, edit, delete, detail links...
When i click the links browser loads to that page and working good...
But i need to popup those views when i click the links in the index page...
i don't know how to do this... i studied many articles but i am confused...
Please help me to solve this with an efficient manner...
Thanks in advance...
Creating a model pop-up within a page isn't something that can be done directly with ASP.NET MVC. You could do it yourself using javascript & css but I would strongly recommend using a JS UI framework to do this. jQuery UI has a pop-up modal box, except they call it a dialog.
The docs for jQuery UI's dialog can be found here. Have a look through the examples to see the fine details of how to set it up. But this is the basic flow of what you need to do:
Download the jQuery UI files needed and include them on your page (CSS/JS files)
Take the html from your create/update/delete views and put it on your index page, wrap them in a div with an appropriate id
When the page loads use jquery ui to target your div's you want to be a popup
Things such as the link you want to make a dialog popup is set by passing options to the dialog initialize method, again the exact options and examples can be found on the docs page.
Refer this : http://jqueryui.com/dialog/ to create a jQuery Dialog box.
<script>
$(function() {
$( "#dialog" ).dialog();
});
</script>
<div id="dialog">
#using(Html.BeginForm()){
#Html.EditorForModel()
<input type='submit' value ='Submit'/>
}
</div>
I have created a page Main.html in witch there is a ViewModel.
In this page there is a button that open a Window Modal and load in it a html page in ajax.
I want to use the viewmodel of the main.html in my window modal, but if I call the viewmodel it do error..
Does someone know how can I resolve?
Load a partial view in to your modal and make sure it has the proper using statement to allow it to use your model:
#using YourApp.YourModels.TheModel
I am developing a mobile website in MVC4 (using Razor view Engine).
The issue I am facing is that When I navigate to different View using RedirectToAction() method, the new view is served but the URL remains the same in the browser.
I searched about it and found that If I disable the AJAX on my page (by setting attribute [data-ajax=false]) then It start working fine(i.e. correct URL is displayed). But Ajax stops working.
But my problem is that I can not disable AJAX for mobile website & I need to display correct URL for each page.
EDIT:
[HttpPost]
public ActionResult Search(string btnSelection)
{
//Some code here...
//Then redirect to another View using following command:
return RedirectToAction("SelectTask", "Task");
}
But to achieve proper URL display in MVC4 mobile, I have to set following attribute in View:
#using (Html.BeginForm("Search", "Task", FormMethod.Post, new { data_ajax = false }))
But this stops the AJAX. Any ideas how to fix this using AJAX?
Please help if you can asap.
Thanks.
Ajax is not for navigating. You must submit form if you have data to save or use a link (e.g. #Html.ActionLink("Home", "Index", "Home")) to redirect to the other view.