How to display modal popup when the if condition is true in View without using Onclick etc? using mvc .net

StackOverflow https://stackoverflow.com/questions/22181055

Question

I have a CreatePage link:

@Html.ActionLink("Create User.", "CreatePage", "User")

Goes to User controller and having some data to populate the view.

In the view I need to have condition : If the data is "empty or null", then populate modal pop up. If the data is greater than empty or null, then no modal pop up.

Please help me out, how I can display modal pop up when there is no record exist.

Thanks!

No correct solution

OTHER TIPS

I'm not sure I understand your question completely, but if the view's modal is null or empty, you can check it and do something different in the view. Like this:

   @if( Model == null ) {
      @Html.Partial("_doThisPartial")
   }
   else {
      @Html.Partial("_doThisOtherPartial")
   }

Used Onload event in the view to populate the modal popup

var TestModal = $('#TestModal'); jQuery(document).ready(function ($) { TestModal.modal('show'); });

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top