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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:02:29+00:00 2026-06-07T22:02:29+00:00

This is my view <form method=post action=/LoadCustomerAndDisplay/Search> <fieldset> <legend>Customer Book</legend> <%= Html.Label(Name) %> <%:

  • 0

This is my view

<form method="post" action="/LoadCustomerAndDisplay/Search">
<fieldset>
    <legend>Customer Book</legend>
    <%= Html.Label("Name") %>

    <%: Html.TextBox("Name") %>
    <br />
    <br />
    <div>
        <input type="submit" value="Sign" />
    </div>
</fieldset>
</form>

This is my controller…

 public ActionResult Search() 
    {
        CustomerModels objCustomer = new CustomerModels();
        var dataval = objCustomer.getData();
        return View(dataval);

}

How can i get the value of Name textbox in the controller and pass it to the the getData like this….

 var dataval = objCustomer.getData(ViewData['Name']);

this i put…showing error on fname….missing adding directive….what’s the issue now…

 <% Html.BeginForm("Search", "LoadCustomerAndDisplay");%>
    <%: Html.TextBoxFor(m => m.fname) %>
    <p>
        <button type="submit">
            Save</button></p>
    <% Html.EndForm();%>
  • 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-07T22:02:32+00:00Added an answer on June 7, 2026 at 10:02 pm

    Use strongly typed view. In your GET action method, pass an object of your ViewModel to the view and use the HTML helper methods to create the input elements. When you submit the form, due to MVC model binding, you will get the values as the property values of the ViewModel in the POST action method.

    Your GET action can stay same

    public ActionResult Search() 
    {
        CustomerModels objCustomer = new CustomerModels();
        var dataval = objCustomer.getData(); 
        // Assuming this method returns the CustomerViewModel object 
        //and we will pass that to the view.
    
        return View(dataval);
    }
    

    so your View will be like

    @model CustomerViewModel
    @using (Html.BeginForm())
    {
      @Html.LabelFor(x=>x.Name)
      @Html.TextBoxFor(x=>x.Name)
      <input type="submit" value="Save" /> 
    }
    

    And have a POST action method to handle this

    [HttpPost]
    public ActionResult Search(CustomerViewModel model)
    {
      if(ModelState.IsValid)
      {
        string name= model.Name;
    
       //  you may save and redirect here (PRG pattern)
      }
      return View(model);
    
    }
    

    Assuming your objCustomer.getData() method in your GET Action method returns an object of CustomerViewModel which has a Name property like this

    public class CustomerViewModel
    {
      public string Name { set;get;}
      //other properties as needed
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<form id=login_frm method=post action = /login/user_auth/> <fieldset> <legend>Login:</legend> <label for=id_email>Email</label> <input type=text name=email id=id_email
This is the code in my view: echo $this->Form->create('Chart'); echo $this->Form->input('username', array('label'=>('Usernames List'), 'empty'=>('Select
Here is the form: <%= form_tag({:controller => home, :action => tellafriend}, :method => post,
How can I post a form to an HttPost Action method and open the
I have a view like this: <div id=basic-information-container> @Html.Action(MyBasicInformation) </div> <div id=cv-container> @Html.Action(MyCv) </div>
This is my view: = form_for(@user) do |f| = f.autocomplete_field @user.city.name, autocomplete_city_name_users_path On the
When click a button,I want to popup a view form bottom,like this! Any help
I have this login form. This form is a grouped table view where the
this time it's about Ruby On Rails. I have a form in the view
I have this view @model IEnumerable<ViewModelRound2> ... <snip> ... @{ using (Html.BeginForm(new { round1Ring3Bids

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.