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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:47:38+00:00 2026-05-22T19:47:38+00:00

I have discovered what appears to be a bug using MVC 3 with the

  • 0

I have discovered what appears to be a bug using MVC 3 with the RemoteAttibute and the ActionNameSelectorAttribute.

I have implemented a solution to support multiple submit buttons on the same view similar to this post: http://blog.ashmind.com/2010/03/15/multiple-submit-buttons-with-asp-net-mvc-final-solution/

The solution works however, when I introduce the RemoteAttribute in my model, the controllerContext.RequestContext.HttpContext.Request no longer contains any of my submit buttons which causes the the “multi-submit-button” solution to fail.

Has anyone else experienced this scenario?

  • 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-22T19:47:39+00:00Added an answer on May 22, 2026 at 7:47 pm

    The problem manifests itself when the RemoteAttribute is used on a model in a view where mutliple submit buttons are used. Regardless of what “multi-button” solution you use, the POST no longer contains any submit inputs.

    I managed to solve the problem with a few tweeks to the ActionMethodSelectorAttribute and the addition of a hidden view field and some javascript to help wire up the pieces.

    ViewModel

    public class NomineeViewModel
        {
            [Remote("UserAlreadyRegistered", "Nominee", AdditionalFields="Version", ErrorMessage="This Username is already registered with the agency.")]
            public string UserName { get; set; }
    
            public int Version {get; set;}
            public string SubmitButtonName{ get; set; }
        }
    

    ActionMethodSelectorAttribute

    public class OnlyIfPostedFromButtonAttribute : ActionMethodSelectorAttribute
        {
            public String SubmitButton { get; set; }
            public String ViewModelSubmitButton { get; set; }
    
            public override Boolean IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo)
            {
                var buttonName = controllerContext.HttpContext.Request[SubmitButton];
                if (buttonName == null)
                {
                    //This is neccessary to support the RemoteAttribute that appears to intercepted the form post
                    //and removes the submit button from the Request (normally detected in the code above)
                    var viewModelSubmitButton = controllerContext.HttpContext.Request[ViewModelSubmitButton];
                    if ((viewModelSubmitButton == null) || (viewModelSubmitButton != SubmitButton))
                        return false;
                }
    
                // Modify the requested action to the name of the method the attribute is attached to
                controllerContext.RouteData.Values["action"] = methodInfo.Name;
                return true;
            }
        }
    

    View

    <script type="text/javascript" language="javascript">
        $(function () {
            $("input[type=submit][data-action]").click(function (e) {
                var action = $(this).attr('data-action');
                $("#SubmitButtonName").val(action);
            });
        });
    </script>
    
        <% using (Html.BeginForm())
           {%>
            <p>
                <%= Html.LabelFor(m => m.UserName)%>
                <%= Html.DisplayFor(m => m.UserName)%>
            </p>
    
            <input type="submit" name="editNominee" value="Edit" data-action="editNominee" />
            <input type="submit" name="sendActivationEmail" value="SendActivationEmail" data-action="sendActivationEmail" />
            <%=Html.HiddenFor(m=>m.SubmitButtonName) %>
    <% } %>
    

    Controller

    [AcceptVerbs(HttpVerbs.Post)]
    [ActionName("Details")]
    [OnlyIfPostedFromButton(SubmitButton = "editNominee", ViewModelSubmitButton = "SubmitButtonName")]
    public ActionResult DetailsEditNominee(NomineeViewModel nom)
    {
        return RedirectToAction("Edit", "Nominee", new { id = nom.UserName });
    }
    
    [AcceptVerbs(HttpVerbs.Post)]
    [ActionName("Details")]
    [OnlyIfPostedFromButton(SubmitButton = "sendActivationEmail", ViewModelSubmitButton = "SubmitButtonName")]
    public ActionResult DetailsSendActivationEmail(NomineeViewModel nom)
    {
        return RedirectToAction("SendActivationEmail", "Nominee", new { id = nom.UserName });
    }
    
    [OutputCache(Location = OutputCacheLocation.None, NoStore = true)]
    public ActionResult UserAlreadyRegistered(string UserName, int Version)
    {
        //Only validate this property for new records (i.e. Version != zero)
        return Version != 0 ? Json(true, JsonRequestBehavior.AllowGet) 
                                  : Json(! nomineeService.UserNameAlreadyRegistered(CurrentLogonDetails.TaxAgentId, UserName), JsonRequestBehavior.AllowGet);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have discovered a strange problem when using UIActionSheet on the iPhone (iOS 4.2).
Now I have discovered Jquery I'm in the process of updating my site. Could
I think I might have discovered an error in the Uri.IsWellFormedUriString method, it might
Scenario: I have several services that I want to be discovered by different clients.
I have PhoneGap app in Android. Now I am ready to publish it, but
I am new to flash, so the solution to this problem may be simple.
I am trying to accessing webpages in C# which are built specifically for iPhones.
Been looking around the web, but not found anything so far... can anyone help?
When I need to find the first node in a TTreeView , I call

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.