title: Want to simulate postback in ASP.Net MVC
body: <p>suppose i have one form and  form has two div container. one div container has few textboxes for submiting login details and another div also has few textboxes those related to register. now my home controller has two action method one is login and another is register. i want that when user click on login button then i will submit form through jquery but before submit i will change action url. the same way i want to call register action method when user click on register button. please guide me how could i do this in mvc with jquery. please help me with sample code.</p>
  
  <p>another person answer like in other forum.</p>
  
  <pre><code>@model MvcForums.Models.StudentModel 
  
  @{ 
  
      using(@Html.BeginForm("Create","Student", FormMethod.Post)) 
      { 
  
          &lt;label&gt; Name&lt;/label&gt; 
          @Html.TextBoxFor(m=&gt;m.FirstName) &lt;br/&gt; 
          &lt;label&gt; From country:&lt;/label&gt; 
          @Html.DropDownListFor(m=&gt;m.CountryId, Model.Countries,"--please select-- ") &lt;br/&gt; 
  
          &lt;input id="btnSave" value ="Login" type="submit" name="commandName"/&gt; 
          &lt;input id="btnRegister" value ="Register" type="submit" name="commandName"/&gt; 
      } 
  
  }
  
  
  [HttpPost] 
  public ActionResult Create(StudentModel studentModel, string commandName) 
  { 
  
      if(commandName == "Login") 
      { 
  
      } 
      else if(commandName == "Register") 
      { 
  
      } 
  
      return View("Index"); 
  }
  </code></pre>
  
  <p>after reading his answer some confusion occur in my mind because i am newbie in mvc and those are as follows</p>
  
  <p>first of all ur code is not readable for ill format. i am new in mvc....just learning it. after reading ur code some confusion occur.</p>
  
  <p>1) why extra bracket u gave <code>@{ }</code></p>
  
  <p>2 u use <code>&lt;label&gt; Name&lt;/label&gt;</code> in form building code. in html4 is there any  tag ? is it html5 specific tag ?</p>
  
  <p>3) <code>@Html.DropDownListFor(m=&gt;m.CountryId, Model.Countries,"--please select-- ")</code></p>
  
  <p>when u building dropdown why u did not specify value &amp; text filed.......how mvc can understand what field will be value &amp; what will be text ? u just bind the model with DropDownListFor()</p>
  
  <p>4) just see it</p>
  
  <pre><code>&lt;input id="btnSave" value ="Login" type="submit" name="commandName"/&gt;
  &lt;input id="btnRegister" value ="Register" type="submit" name="commandName"/&gt;
  </code></pre>
  
  <p>both the button name is <code>commandName</code> ? is it correct ?</p>
  
  <p>when user click on any button then how button name will be pass to</p>
  
  <pre><code>public ActionResult Create(StudentModel studentModel, string commandName)
  </code></pre>
  
  <p><code>Create()</code> method ? please tell me how implicitly command name will be pass to <code>Create() and how commandName</code> variable at server side can hold the button name.</p>
  
  <p>i have too much confusion after reading ur code. if possible please discuss all my points in details. thanks</p>