Reputation: 3884
Is it possible to call jquery pop up from code behind in mvc3. I am doing couple of validations on page through code behind and wants to show the validation success message. I tried using ScriptManager.RegisterStartCLient but looks like it is deprecated.
Is there anything like this in mvc3?
Upvotes: 0
Views: 1181
Reputation: 3884
I added a property to the viewModel and when I was rendering the view , I checked the property and showed the jquery pop up.
Something like :
@if(Model.IsSUccess)
showDialog();
Upvotes: 0
Reputation: 1288
Not sure what code behind means in context of ASP.NET MVC. But possibly you should pass your validation message from Controller
to View
using ViewBag
. For example:
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.Message = "Your message";
return View();
}
}
And then in View render the script
with razor if message is presence:
@if (ViewBag.Message != null) {
<script>$('#example').some_popup_plugin("@ViewBag.Message")</script>
}
Upvotes: 2