0

Im using the following script in the ASP page (MVC5 - index.cshtml file - view),what I need is that instead of the alert box to open pop-up window with user and password,how should I do that? in the mvc project tool box there is control but how should I create them in pop-up and call it inside the script

 <script type="text/javascript"> 
      $(document).ready(function () { 
         $("#M").change(function () { 
          if ($(this).val() == "F") { 


      $('#dv').dialog({
            width: 300, 
            height: 300,
            modal: true,
            resizable: true,
            open: function(type,data) {
              $(this).parent().appendTo("form");},
            autoOpen: true,  
            title: 'Sample'
        });
       } 
           } 
         }); 
      }); 
</script>

Add my view code

@model IEnumerable<Ad.Models.Ad>
<script src='https://code.jquery.com/jquery-1.11.0.min.js'></script>
<script src='https://code.jquery.com/ui/1.9.2/jquery-ui.min.js'></script>


    <script type="text/javascript"> 
  $(document).ready(function () { 
     $("#M").change(function () { 
      if ($(this).val() == "F") { 


  $('#dv').dialog({
        width: 300, 
        height: 300,
        modal: true,
        resizable: true,
        open: function(type,data) {
          $(this).parent().appendTo("form");},
        autoOpen: true,  
        title: 'Sample'
    });
   } 
       } 
     }); 
  }); 

Hai
<h3>My APP</h3>


p>
    @using (Html.BeginForm())
    {

    }


    @*<br style="margin-bottom:240px;" />*@
    @Html.ActionLink("Create", "Create",
        null, htmlAttributes: new { @class = "mybtn" })
    <p>

    </p>


    <style type="text/css">
        a.mybtn {
            background: #fa0088;


        }
    </style>

  <table class="table">
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.Name)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Email)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Gender)
     </th>
            <th></th>
        </tr>


   @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.Name)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Email)
                </td>
                <td>
                    @Html.DropDownListFor(modelItem => item.Geneder, item.Gender, new { id = "M" })

                </td>
                <td>
                    @Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
                    @Html.ActionLink("Details", "Details", new { id = item.ID }) |
                    @Html.ActionLink("Delete", "Delete", new { id = item.ID })
                </td>

            </tr>

2 Answers 2

1
 $("#M").change(function () { 
          if ($(this).val() == "F") { 
              $('#dv').dialog({
                width: 300, 
                height: 300,
                modal: true,
                resizable: true,
                open: function(type,data) {
                  $(this).parent().appendTo("form");},
                autoOpen: true,  
                title: 'Sample'
            });
           } 
 });  

Demo:

http://jsfiddle.net/TYHBq/2/

Sign up to request clarification or add additional context in comments.

9 Comments

Thanks RGS ,I have added your code as in the updated post and its not working can you please check if I miss something?
@JeanTehhe, You have to add 'id' for div tag. <div id="dv"/>
where?since when I add it after the script nothing happen,I dont see any pop-up when changing the item on drop down
@JeanTehhe, In the demo I have created one 'div' and assigned 'id' to div as 'dv'. Inside that I have added 'Hai' message. Initially it is set to display 'none' in css.When the selection value is 'F' then the dialgo box appears.
Sorry but Since Im new to this Im not sure that I got you ,when I add the div noting happen ...
|
0

In mvc jquery-ui library is already included. just add the particular bundle.

@Scripts.Render("~/bundles/jqueryui")

Now you can use jquery ui dialog() as alert

<script>
    $("<div>Test messsage</div>").dialog();
</script>

1 Comment

I have added the second code in the script instead of the aleart and noting happen...maybe I need to do addtional steps ? I found the @Scripts.Render in the layout where is the Jquery libarary?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.