Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7503087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:06:00+00:00 2026-05-29T21:06:00+00:00

I am working on razor project where I need to display jquery modal popup.

  • 0

I am working on razor project where I need to display jquery modal popup. The popup shows up fine when it’s not started from the accordion, but once I put it there, the button doesn’t show the popup, but instead triggers the function from different button.

I have this in the markup:

@using (Html.BeginForm("ASPXView", "Report", FormMethod.Post)) {
    @Html.ValidationSummary(true, 
         "Password change was unsuccessful. Please correct the errors and try again.")
    <div>
        @Html.Hidden("Id", Model.Report.Id)
        <div id="accordion">

            @foreach (var item in Model.Parameters)
            {
                <h3><a href="#">@Html.LabelFor(m => item.Name, item.Prompt)</a></h3>
                <div>
                    <div class="editor-label">
                        Search @*Html.TextBox("Search")*@ 
                        <input id="@("Search" + item.Name)" type="text" name="q" data-autocomplete="@Url.Action("QuickSearch/" + item.Name, "Report")" />
                    </div>

                    <div class="editor-field">
                        <select multiple id="@("Select" +item.Name)" name="@("Select" +item.Name)"></select>                           
                    </div>

                    <div class="removed">                     
                     <button id="opener">Open Dialog</button>               
                    </div>              
                </div>
            }         
        </div>
        <p style="text-align: right">
            <input type="submit" value="Submit" />
        </p>
    </div>
}
<div id="dialog" title="Basic dialog">
    <p>Test Content.</p>
</div>

JS code:

<script type="text/javascript">
    var openDialog = function () {

        $('#dialog').dialog('option', 'buttons', {
            "Cancel": function () {
                $('#dialog').dialog('close');
            }
        });


        $('#dialog').dialog('open');

    };
    $(function () {
        $("#dialog").dialog({
            autoOpen: false,
            show: "blind",
            hide: "explode"
        });
        $('#opener').click(openDialog);
    })

</script>

As I said, when I’ll place Open Dialog below the dialog div, outside of accordion div, the popup comes up normal, but once I put the button there, popup doesn’t come out.

Thanks in advance for every advice


JS CODE UPDATE:

<script type="text/javascript">
    $(function () {
        $('#opener').click(function () {
            $("#dialog").dialog('destroy');
            $("#dialog").attr("title", "Your Title Heren");
            $("#dialog").dialog({
                height: 620,
                width: 700,
                modal: true
            });
        });

    })
</script>

After replacing the code I had with this code, I can see the popup only from the 1st item in the accordion, but not from the other two.
Also, once the popup shows up on the screen, postback is happening, and event which is attached to another button, the submit button happens. Why do you think is that?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T21:06:04+00:00Added an answer on May 29, 2026 at 9:06 pm

    may be you should have your jQuery Like this

    $('button[id^=opener]').click(function (){
     $("#dialog").dialog('destroy');
        $("#dialog").attr("title", "Your Title Heren");
        $("#dialog").dialog({
            height: 620,
            width: 700,
            modal: true
        });
    });
    

    Edited:

    Mark up should go like this

    @int i = 0;
     @foreach (var item in Model.Parameters)
            {
              // your rest of the Code
                    <div class="removed">                     
                     <button id="opener"+i>Open Dialog</button>               
                    </div>              
                </div>
    i++;
            }      
    

    jQuery Selector will be Like this

    $('button[id^=opener]').click(function (){
    // Rest Continues
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on my 1st mvc razor project. I set the project and
I am working on project using MVC 3.0(Razor framework). I am trying to get
I am working with razor view engine in asp.net mvc3. Now, I need an
Alright guys, Need some help! Im working with asp.net mvc3 razor (and am fairly
Working with MVC3, Razor, Jquery, Javascript. The below code loops through and displays a
I am working on a project which adopted ASP.NET MVC3(Razor) tech. Now, I have
I've been moving a fairly new project from ViewPages to Razor today, and all
I'm working with the System.Web.Helpers.WebGrid in an ASP.NET MVC 3 Razor project, and I'm
I am currently working on a MVC3 project with Razor. I have switchen on
We are working on an ASP.NET MVC 3 project and taking advantage of Razor

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.