2015-10-13 24 views
-6

我是新的MVC。MVC基本 - 如何獲得網址中的HTML按鈕

我有簡單的HTML網站,在那裏我有兩個三個輸入

  1. 輸入寫的電子郵件地址
  2. 一個複選框
  3. 按鈕

我有一個HomeController的這對方法

[HttpGet] 
public ActionResult Index() 
{ 
    return View(); 
} 

我想單擊按鈕後生成方法[HttpPost]

現在,經過我點擊inputbutton在我的網址我只有一個變化 點擊之前

http://localhost:52254/Home/Index 

http://localhost:52254/Home/Index? 

有一種形式

<form> 
    <div class="col-xs-3"> 
    <input type="email" class="form-control" id="email" placeholder="Wpisz adres email"> 
    </div> 
    <br /> 
    <label class="checkbox-inline"> 
    <input type="checkbox" /> 
    </label> 
    <br /> 
    <a href="/Controller/View"> 
    <input type="submit" value="Sign" class="btn btn-primary"/> 
    </a> 
</form> 
+1

好像什麼你問的是極爲基礎和覆蓋在無數的教程。你有沒有做過任何研究,看看它是如何完成的? – mason

+0

是的,我做到了。我知道它100%基本,但我真的找不到它;( – miechooy

+0

按照微軟教程,他們很好開始http://www.asp.net/mvc/overview/getting-started/introduction/getting-started –

回答

0

變化的像這樣的代碼


 
@using (Html.BeginForm()) 
 
      { 
 
<div class="col-xs-3"> 
 
    <input type="email" class="form-control" id="email" placeholder="Wpisz adres email"> 
 
    </div> 
 
    <br /> 
 
    <label class="checkbox-inline"> 
 
    <input type="checkbox" /> 
 
    </label> 
 
    <br /> 
 
    <a> 
 
    <input type="submit" value="Sign" class="btn btn-primary"/> 
 
    </a> 
 
}