2014-07-24 20 views
0

我的工作我的第一 ASP.net MVC項目,並且我在一種形式中使用多個按鈕時遇到了一些問題。如何使註冊/登錄行動在一種形式

當我的用戶類型的用戶名密碼&,然後點擊登錄,就意味着它將進入歡迎頁面

如果用戶嘗試註冊意味着它會去另一個表單字段獲得的個人信息。 最後所有給定的信息都需要存儲在數據庫中並將用戶重定向到歡迎頁面。

@using (Html.BeginForm("about", "home", FormMethod.Post, new { @id = "msform" })) 
{ 
    @Html.AntiForgeryToken() 
@Html.ValidationSummary() 





<!-- progressbar --> 

    <ul id="progressbar"> 
     <li class="active"></li> 
     <li></li> 
     <li></li> 
    </ul> 
<!-- fieldsets --> 
    <fieldset> 
     <h2 class="fs-title">Create your account</h2> 
     <h3 class="fs-subtitle">Take 60 Seconds With Us</h3> 
     <input type="text" name="UsersName" placeholder="Username" /> 
     <input type="password" name="Passsword" placeholder="Password" /> 
     <input type="button" name="next" class="next action-button" value="Sign Up" /> 
     <input type="button" name="next" class="nexts action-login" value="Log In" /> 
     <input type="submit" value="+" /> 
    </fieldset> 
    <fieldset> 
     <h2 class="fs-title">Personal Information</h2> 
     <h3 class="fs-subtitle">We will never share</h3> 
     <input type="text" name="phone" placeholder="Email" /> 
     <input type="text" name="phone" placeholder="Phone Number" /> 
     <input type="text" name="date" placeholder="Date of Birth" /> 
     <input type="text" name="gender" placeholder="Gender" /> 
     <input type="button" name="previous" class="previous action-button" value="Previous" /> 
     <input type="button" name="next" class="next action-button" value="Next" /> 
    </fieldset> 
    <fieldset> 
     <h2 class="fs-title">Make SomeOne Alive</h2> 
     <h3 class="fs-subtitle">A donor today! A hero tommorow!</h3> 
     <input type="text" name="fname" placeholder="Blood Group" /> 
     <input type="text" name="lname" placeholder="Are You ?" /> 
     <input type="text" name="phone" placeholder="State" /> 
     <input type="text" name="phone" placeholder="City" /> 
     <input type="button" name="previous" class="previous action-button" value="Previous" /> 
     <input type="submit" name="submit" class="action-button" value="Submit" /> 
    </fieldset> 

} 

https://onedrive.live.com/redir?resid=D9BCBB2A676D6E13!5561&authkey=!ACAv8vrk-2Any98&v=3&ithint=photo%2cjpg

https://onedrive.live.com/redir?resid=D9BCBB2A676D6E13!5562&authkey=!ANwuCjzTkoSJVCA&v=3&ithint=photo%2cJPG

但現在,我已經把我的觀點窗體上的登錄按鈕,我完全失去了。我不知道如何在用戶單擊登錄按鈕時表示它將重定向,如果signUp表示它將重定向到另一個表單。如何實現形式

Final

+0

你有沒有在HTML/Javascript/jQuery的任何編程? –

+0

No Erik。我是網絡開發新手 – Sirushti

回答

0

給你的按鈕名稱,然後測試他們在發佈的數據服務器端的存在。只有被點擊的人會在那裏:

<button type="submit" name="_SignUp">Sign Up</button> 
<button type="submit" name="_LogIn">Log In</button> 

然後,在你的行動:

if (Request.Unvalidated["_SignUp"] != null) 
{ 
    // do sign up 
} 

if (Request.Unvalidated["_LogIn"] != null) 
{ 
    // do log in 
} 

或者,你可以或者只是占卜用戶的意圖,以試圖檢索用戶對象標誌他們在,如果你沒有匹配,然後做註冊。但是,這幾乎使按鈕不重要,並可能導致用戶單擊「註冊」並實際登錄,反之亦然。這並不重要,但最好管理用戶的期望。如果他們認爲他們沒有賬戶,但實際上他們可能想知道這一點。

+0

hello Chris, 我是開發新手。如果您不介意,請爲我提供一步一步的指南以實施SignUp表單。 – Sirushti

+0

對不起,但超出了StackOverflow的範圍。網上有無數的文章和教程,還有許多可以學習的優秀書籍。而且,不要太瘋狂,但學習是通過做。如果您不願意或無法自行提供解決方案,並且有可用的許多資源,那麼也許您應該重新考慮成爲開發人員。再次,不是我的意圖冒犯,在這裏,但老實說,這是對你或任何想成爲開發者的重要建議。 –

+0

老實說我接受它: – Sirushti