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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:54:53+00:00 2026-05-24T11:54:53+00:00

So I have a view that allows users to Approve or Reject items listed

  • 0

So I have a view that allows users to Approve or Reject items listed on the page. When approved, I simply use the @Ajax.ActionLink to post to the appropriate controller action. When the user Rejects an item, the user is required to enter a reason for the rejection. I’m found code on the internet that gave me a popup dialog and added a textbox and OK/Cancel buttons. I can capture the input from the user and show it in an alert, but now I need to complete it and I’m not sure how.

1st – I need add functionality to pass to my jquery link handler, the ID associated with the Item being rejected.

2nd – I need a way to call my Controller Action from the jquery.

Here is the code I have up to this point.

My link is simply an ‘a’ tag. I can’t see to post the code for this without removing the <>
a href=”#dialog” name=”modal” Reject a

My script handles this here

    $(document).ready(function () {

        //select all the a tag with name equal to modal
        $('a[name=modal]').click(function (e) {
            //Cancel the link behavior
            e.preventDefault();

            //Get the A tag
            var id = $(this).attr('href');

            //Get the screen height and width
            var maskHeight = $(document).height();
            var maskWidth = $(window).width();

            //Set heigth and width to mask to fill up the whole screen
            $('#mask').css({ 'width': maskWidth, 'height': maskHeight });

            //transition effect     
            $('#mask').fadeIn(1000);
            $('#mask').fadeTo("slow", 0.8);

            //Get the window height and width
            var winH = $(window).height();
            var winW = $(window).width();

            //Set the popup window to center
            $(id).css('top', winH / 2 - $(id).height() / 2);
            $(id).css('left', winW / 2 - $(id).width() / 2);

            //transition effect
            $(id).val('');
            $(id).fadeIn(2000);

        });

Here is my pop up dialog and the mask that grays out the screen when the dialog is opened.

    <div id="boxes">


    <div id="dialog" class="window">
        Enter the reason for rejection:</br>
        <textarea class="multiline" id="rejectreason" rows="10" cols="20"></textarea><br/>
        <div style="margin-left: 120px"><input type="button" value="OK" class="ok" style="width:70px"/> &nbsp;<input type="button" value="Cancel" style="width:70px" class="close"/>       
    </div>
</div>


<!-- Mask to cover the whole screen -->
   <div id="mask"></div>
</div>

It could be that I’m going about this completely wrong, but it’s all I could find on line and pieced it all together from there. As this is my first experience with jquery and MVC, I’m struggling a bit here. Any help would be greatly appreciated.

Thanks

UPDATE

OK, so I added a data-id attribute to my link that allows me to get the ID of the link clicked. I tested it using this code and it works.
var iD = $(this).attr(‘data-id’);

I now need to pass this value to my dialog so I can then retrieve it again when the OK button on the dialog is clicked. I can set a hidden field on the page if necessary and retrieve it from there.

  • 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-24T11:54:53+00:00Added an answer on May 24, 2026 at 11:54 am

    Here is some code to get you on the right path…

    jQuery Ajax:

    $(document).ready(function () {
        $("#InputButtonId").click(function () {
            $.ajax({
                url: '@Url.Action("SomeAction", "Controller")',
                type: 'POST',
                data: { id: $("#hidden").val(), reason: $("#rejectreason").html },
                dataType: "json",
                beforeSend: function () {
                },
                success: function (result) {
                    // Do action if success
                },
                error: function (result) {
                    // Do action if error
                }
            });
            return false;
        });
    });
    

    And the controller action:

    [HttpPost]
    public JsonResult SomeAction(string id, string reason)
    {
        //Perform Actions
        return Json(new
        {
            value1 = value1,
            value2 = value2
        }, JsonRequestBehavior.AllowGet);
    }
    

    Hope this helps.

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

Sidebar

Related Questions

I've made a page that allows users to view a list of batch files
I have a form that allows users to view some terms and conditions, which
We have an E-Commerce site that allows users to buy products, view their shopping
I have the following: POST page that allows users to write text in CKEditor
I have a view controller that allows users to add an nsstring to an
I have a Richedit that allows my users to format and view error messages
We have FireSymfony that allows one to view the Symfony, PHP variables in a
I made a .NET Windows form that allows users to view a particular document
I have an application that loads different documents to the server, and allows users
I'm making an application that allows users to view task lists stored in different

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.