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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:18:48+00:00 2026-05-16T07:18:48+00:00

<% using (Html.BeginForm(SubmitUserName)) { %> <input type=’text’ name=’user-name’ /> <input type=’submit’ value=’Send’ /> <%

  • 0
<% using (Html.BeginForm("SubmitUserName")) { %>
    <input type='text' name='user-name' />
    <input type='submit' value='Send' />
<% } %>

What should be a signature of a corresponding Action method to accept user-name parameter?

public ActionResult SubmitUserName(string user-name) {...}

Method signature above does not work for some reason 😉

I know there is an ActionNameAttribute to handle situation with a dash in action name. Is there something like ParameterNameAttribute?

  • 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-16T07:18:49+00:00Added an answer on May 16, 2026 at 7:18 am

    As everyone has noted, the easiest fix would be not to use a dash. If you truly need the dash, you can create your own ActionFilterAttribute to handle it, though.

    Something like:

    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
    public class ParameterNameAttribute :  ActionFilterAttribute
    {
        public string ViewParameterName { get; set; }
        public string ActionParameterName { get; set; }
    
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if(filterContext.ActionParameters.ContainsKey(ViewParameterName))
            {
                var parameterValue = filterContext.ActionParameters[ViewParameterName];
                filterContext.ActionParameters.Add(ActionParameterName, parameterValue);   
            }
        }
    }
    

    You would then apply the filter to the appropriate Action method:

    [ParameterName( ViewParameterName = "user-data", ActionParameterName = "userData")]
    [ParameterName( ViewParameterName = "my-data", ActionParameterName = "myData" )]
        public ActionResult About(string userData, string myData)
        {
            return View();
        }
    

    You would probably want to enhance the ParameterNameAttribute to handle upper/lower case, but that would be the basic idea.

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

Sidebar

Related Questions

@using(Html.BeginForm()){ Name: @Html.TextBoxFor(o => o.Name) <input type=submit value=submit /> } this gives error CS1002:
I have this code in mvc 3 razor @using (Html.BeginForm(MyAction, MyController)) { <input type=text
Ok so I want to know how <% using (Html.BeginForm()) { %> <input type=text
I have code in View: @using (Html.BeginForm(MyAction, MyController) { <input type=text id=txt /> <input
Here's the view @using (Html.BeginForm(Deleted, Location)) { Html.Hidden(LocationID, Model.LocationID ); <input type = submit
I have used to have @using (Html.BeginForm()) { <input type=submit formaction=/home /> } And
I have a page with 2 input type=text.. @model MVC3.ViewModel.TalkToUsVM @using (Html.BeginForm()) { <ul>
@using (Html.BeginForm()) { @Html.TextBoxFor(m => m.Name, new { @Value = Name }) @Html.TextBoxFor(m =>
@using (Html.BeginForm(Index, Checkout, FormMethod.Post)) { @Html.AntiForgeryToken(App.WebUI.Helpers.SecurityHelpers.AntiforgeryTokenSalt) <input type=hidden name=amount value=@Model.PackageCost/> <input type=hidden name=currency value=$/>
I am trying to submit when a dropdownlist changes by doing this @using (Html.BeginForm(testAction,

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.