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 4545384
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:48:21+00:00 2026-05-21T15:48:21+00:00

I am using @Darin Dimitrov’s method explained in Loading a partial view in jquery.dialog

  • 0

I am using @Darin Dimitrov’s method explained in Loading a partial view in jquery.dialog to allow users to click on one of their Private Messages and view it inside a modal box. I am using ASP.NET MVC3 and Razor as my view engine. But I’m having some trouble getting this to work… Below is what I’ve attempted so far:

The messages are displayed in a table:

<tr id="@item.Id" class="openConversationLink">
    <td class="newMessageStatus">@MessageStatus(item)</td>
    <td class="msgSenderName">@item.Sender</td>
    <td class="msgSubject">@item.Subject</td>
    <td class="msgLastUpdated">@item.LastUpdated</td>
    <td class="modalItemActions"></td>
</tr> 

And inside the same partial view, I got the following script block:

<script type="text/javascript">
    $(function () {
        $("#conversationModal").dialog({
            autoOpen: false,
            width: 850,
            height: 600,
            resizable: false,
            draggable: false,
            modal: true,
            open: function (event, ui) {
                var convId = ui.attr('id');
                alert(convId);
                $(this).load('@Url.Action("Conversation", "Message", new { conversationId = convId})');

            }
        });

        $(".openConversationLink").click(function () {
            $("#conversationModal").dialog('open');
        });
    });
</script>

Basically, I’m not sure what the event and ui parameters inside the open handler refer to. So a little explanation on both would be appreciated. But anyway, even the messages do not get displayed now, I keep getting those error:

Compiler Error Message: CS0103: The
name “convId” does not exist in the
current context. Source:
$(this).load(‘@Url.Action(“Conversation”,
“Message”, new { conversationId =
convId})’);

Basically, I do not want that line to get triggered until I actually click on one of the rows (to open the conversation dialog), but it seems like it’s actually getting triggered when the Messages page opens.

UPDATE:

Here’s my jQuery code now:

$(function () {
    $("#conversationModal").dialog({
        autoOpen: false,
        width: 850,
        height: 600,
        resizable: false,
        draggable: false,
        modal: true,
        open: function (event, ui) {
            var convId = event.target.attr('id');
            alert(convId);
            $(this).load('Message/Conversation/' + convId);

        }
    });

    $(".openConversationLink").click(function () {
        $("#conversationModal").dialog('open');
    });
});

Anything that can be done about that? 🙂

  • 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-21T15:48:22+00:00Added an answer on May 21, 2026 at 3:48 pm

    Before you go any further, you need to understand the key thing here >

    Url.Action() method is working on the server side. Whatever is passed on to it has to be decided on the server side. Any variables declared in Javascript at the client-side are totally oblivious to the server-side code hence the compiler is trying to find the convId at the server-side code and obviously can’t find it. So it gives the error.

    Now saying that, we need to find a way to pass the convId to the server. For that you would need to do some manual string concatenation at the client-side. you can do something like this >

    '@Url.Action("Conversation", "Message")' + '?conversationId='+convId

    You see we used the server side code to generate /Message/Conversation and then concatenated it at client side to make it /Message/Conversation/?conversationId=valueOfconvId

    I hope it makes sense 🙂

    EDIT:

    <script type="text/javascript">
    var clickedId;
       $(function () {
            $("#conversationModal").dialog({
                autoOpen: false,
                width: 850,
                height: 600,
                resizable: false,
                draggable: false,
                modal: true,
                open: function (event, ui) {
    
                    $(this).load('Message/Conversation/' + clickedId);
    
                }
            });
    
            $(".openConversationLink").click(function () {
                clickedId = $(this).attr("id");
                $("#conversationModal").dialog('open');
            });
        });
    </script>
    

    makes sense now? we are saving the id of the clicked tr in a global variable

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

Sidebar

Related Questions

Problem: jQuery DataTables server-side processing using ASP.NET WebForms. Solution: Darin Dimitrov answered the question
I have been using the following code for loading JQuery in all of my
Thanks to Darin Dimitrov's suggestion I got a big step further in understanding good
I'm using the Telerik RadSpell control in one of our touchscreen applications. I've managed
I have a partial view where I render, if the user has choosen an
In a previous question , @Darin Dimitrov answered : In your case the worst
Earlier today I posted another post where @Darin Dimitrov helped me great, however once
Is there any advantage in using one over the other? Should I use the
I am using the latest version of jQuery and ASP.NET MVC 3 with the
I am using the method described in the following LINK and I am using

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.