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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:10:31+00:00 2026-06-15T20:10:31+00:00

I want to add popups in which user can add comments for each grid

  • 0

I want to add popups in which user can add comments for each grid on web. I want to add this comment to database and close popup without refreshing main page.
How can I do it? Here is my code.

$('a.dialog').click(function () {
    var x = jQuery(this).position().left + jQuery(this).outerWidth();
    var y = jQuery(this).position().top - jQuery(document).scrollTop();

    $.get(
        this.href, 
        function (result) {
            $(result).dialog({
                modal: true,
                width: 500,
                position: [x, y]
            });
        }
    );
    return false;
});

Here is Post from controller:

[HttpPost]
public ActionResult Comment(CommentsModel model)
{
    try
    {
        model.UserId = Storage.UserGetActive().Id;
        Storage.CommentInsert(model);
        return RedirectToAction("Index");
    }
    catch (Exception e)
    {
        return RedirectToAction("Error", e);
    }
}

I know I’m doing it wrong. How can I just save comment and close popup?

EDIT
I’m just making link to it, like this:

<a class="dialog" href="/Dashboard/Comment/'+clips[i-1]+'">Comment</a>

This is what I have in my view:

@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
    <fieldset>
        <legend>Add new comment</legend>
        @Html.HiddenFor(m => m.MetriceId)
        <div>
            @Html.LabelFor(m => m.Comment)
        </div>
        <div >
            @Html.EditorFor(m => m.Comment, new { style = "width:450px; height:70px" })
            @Html.ValidationMessageFor(m => m.Comment)
        </div>
        <p>
            <input type="submit" value="Save Comment" />
        </p>
    </fieldset>
}
  • 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-15T20:10:33+00:00Added an answer on June 15, 2026 at 8:10 pm

    Firstly update your action method so that it is not redirecting and simply returns a status:

    [HttpPost]
    public ContentResult Comment(CommentsModel model)
    {
        try
        {
            model.UserId = Storage.UserGetActive().Id;
            Storage.CommentInsert(model);
            return Content("success"); 
        }
        catch (Exception e)
        {
            return Content("error");
        }
    }
    

    You need to set up your dialog to post to your action. See JQuery help

    Firstly add html to your page for your dialog to exist

    <div id="dialog-confirm" title="Comment on item">
        <!-- Put whatever markup you require in here -->
        <!-- You will need a placeholder for the id of the item you are commenting on  -->
    </div>
    

    Secondly initialise you dialog:

    $(function() {
        $( "#dialog-confirm" ).dialog({
            autoOpen: false, //Dialog is initialised closed
            resizable: false,
            height:140,
            modal: true,
            buttons: {
                "Save Comment": function() {
                    // NOTE: We are making a jQuery post action
                    $.post(<url>, // Replace url
                            // Build your data model eg: 
                            // { UserId: <userId>, Comment: <comment> ...}
                            <data>, 
                            // This is what is actioned after the post 
                            // returns from the server
                            function(result) 
                            {
                                // Check if successful
                                if(result == 'success') {
                                    //Simply the dialog
                                    $( this ).dialog( "close" );
                                }
                                else {  //an error occured
                                    //Update dialog html to show error
                                }
                            }                                            
                },
                Cancel: function() {
                    $( this ).dialog( "close" );
                }
            }
        });
    });
    

    Lastly you need to set up your links to open the dialog:

    $('a.dialog').on('click', function(e){
        // Update the dialog to contain data of the item you are 
        // commenting on so you can grab it and post to the server 
        $( "#dialog-form" ).dialog( "open" );
    }
    

    The above should be enough to give you a pop up. Note, this is not your full solution

    I would recommend reading through the jQuery docs on modals and posts:

    • jQueryUI modal
    • jQuery post
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want add new Feed item on entity persist and update. I write this
I want add my custom sidebar next right column all page. Please check this
How can I create an Chrome extension, which will add an icon to the
They reason i want to do this is so that I can actually have
I have a scenario where i want user to open a popup or other
I have an application which has a 'user.as' class and I have a popup
I want to deploy my application. i followed this step but i can't get
I have a simple user control which I want to create dynamically every time
I want to add a pagination inside the fancybox. But with the clickevent which
I want to add share this on Facebook to a page. I've got this

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.