alice7
alice7

Reputation: 3884

Call client side jquery popup from code behind in MVC

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

Answers (2)

alice7
alice7

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

user20140268
user20140268

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

Related Questions