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

  • Home
  • SEARCH
  • 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 8823561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:23:14+00:00 2026-06-14T06:23:14+00:00

In ASP.NET MVC, I am trying to show a jqueryUI modal dialog, by calling

  • 0

In ASP.NET MVC, I am trying to show a jqueryUI modal dialog, by calling a function that resides in an external js file. The reason for this is that i want to have a js method written somewhere and just call it with some parameters, instead of copypasting it on every page.

this is my CustomFunctions.js file:

function CustomFunctions() { };

CustomFunctions.prototype.loadModalDialog = function (dialogDivID, callerElementDivID, dialogSize, actionControllerName, container)
{
  var dialogElement = $('#' + dialogDivID);
  var callerElement = $('#' + callerElementDivID);
  dialogElement.dialog
  (
    {
        autoOpen: false,
        show: "slide",
        width: dialogSize,
        resizable: false,
        modal: true
    }
  );

callerElement.click(function() 
{
    dialogElement.load("@Url.Action(" + actionControllerName +")", function() 
    {
        $(container).dialog('open');
    });
    return false;
})

}

now, on my List.cshtml view, I have written the following:

@Html.ActionLink(
        "click me", 
        "List", 
        new {string.Empty},
        new { onclick = "Javascript:showModal();" }
        );

@Scripts.Render("~/bundles/custom");
<script>
    function showModal()
    {
        var custom = new CustomFunctions();
        custom.loadModalDialog("my-dialog", "show-modal", 400, "List", this);
    }
</script>

The problem is that the modal dialog does not pop. On client side debugging, it enters the loadModalDialog, it finds all variables properly, it goes through all the js code, throws no error (which puzzles me) but does not show the dialog.

Am I missing something?
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-06-14T06:23:15+00:00Added an answer on June 14, 2026 at 6:23 am

    this will not work in an external js file

    “@Url.Action(” + actionControllerName +”)”

    this works when inline with the the template because the tempplate is prased and rendered before it’s sent to the client. when this is put into an exteneral js file it’s a literal string.

    custom.loadModalDialog(“my-dialog”, “show-modal”, 400, “List”,
    this /*probably not what you’d expect*/);

    passing this at this point in the code is passing either the document or window object. you then try to call dialog('open') on the container, which is not the dialog object you are expecting.

    There is also the issue of calling jquery outside of the document.ready event. unless showModal() is called after the page loads the jquery functions will not work.

    Any of the latest bowsers have a javascript/console for debugging js.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: File Upload ASP.NET MVC 3.0 I am trying to just print out
I'm trying to implement a simple ActionLink that will delete records using ASP.NET MVC.
I'm working on my first ASP.NET MVC 3 application and I'm trying to show
Using ASP.NET MVC when trying to get the information stored on my Session[objectName] from
I'm trying out ASP.NET MVC, but, after reading a huge tutorial, I'm slightly confused.
In an ASP.NET MVC 3 (Razor) project i 'm trying to upload a picture:
I am new to ASP.NET-MVC and I am trying to create a simple blog
I am trying to convert the popular asp.net MVC 2.0 solr.net sample app code
I'm trying to create ASP.NET MVC Application with Entity Framework, which has One to
I was trying to use RoR or ASP.NET MVC but at my first impression

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.