Reputation: 57
I am using MVC3, C# engine
My question : I am checking from my controller if there is an Active batch and if there is not then display the result. But if there is a Active batch need to display a modal pop up alert
if (!CheckActiveStatus())
{
GetAllErrors(batchID);
}
else
{
// Need to show modal alert box here
}
return View();
Should I create a partial view and call that page. ? I checked few articles but unable to understand how to implement. Any help is appreicated.
Thanks
Upvotes: 0
Views: 4266
Reputation: 36073
Your controller is server-side code. It is not possible to show a dialog box on your client from server-side code.
What you need to do is have your controller "tell" the view to show the dialog box.
Model:
class MyModel
{
public bool IsShowAlert { get; set; }
}
Controller:
var model = new MyModel()
{
IsShowAlert = false;
};
if (!CheckActiveStatus())
{
GetAllErrors(batchID);
}
else
{
// Need to show modal alert box here
model.IsShowAlert = true;
}
return View(model);
View:
@model MvcApplication1.MyModel
@* .... *@
@if (Model.IsShowAlert)
{
// Do what you need to to show the alert
}
Upvotes: 1