2016-06-09 73 views
0

從上ForgotPassword鏈接我的登錄頁面,用戶點擊並進入該頁面填寫了一個表格,並要求一個新的密碼如何在ASP.NET MVC中創建一個簡單的引導模式對話框

http://localhost:2350/Account/ForgotPassword 

現在當他們在該頁面中點擊保存時,他們的請求已創建。 所以我需要的僅僅是一個引導模態對話框彈出「您的請求已提交」和它「確定」按鈕,當他們點擊OK需要他們回到登錄頁面。

我從來沒有做過Ajax,彈出對話框等。像這樣。你能指點我一些教程代碼,不太複雜,不能遵循和重現嗎?因爲我的模式非常簡單,不包含任何數據,只有一個靜態文本和一個OK按鈕,可以重定向到登錄頁面。

+0

您使用的引導程序版本是什麼? – Ram

回答

5

你可以設置你的Bootstrap Modal這樣的:

<div class="container"> 

    <h3>Modal Example</h3> 

    <!-- Button to trigger modal --> 
    <div> 
    <a href="#myModal" role="button" class="btn" data-toggle="modal">Launch Modal</a> 
    </div> 

    <!-- Modal --> 
    <div id="myModal" class="modal hide" tabindex="-1" role="dialog"> 
    <div class="modal-header"> 
     <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> 
     <h3>Modal Example</h3> 
    </div> 
    <div class="modal-body"> 

     <p> 
     This is your body 
     </p> 

    </div> 
    <div class="modal-footer"> 
     <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button> 
     <button id="submitButton" class="btn btn-primary">OK</button> 
    </div> 
    </div> 

</div> 

而在你的JavaScript代碼,你趕上click事件OK按鈕。然後,調用ajax並重定向到登錄頁面。

$('#submitButton').click(function() { 

    // Call AJAX here 
    $.ajax({ 
    method: "POST", 
    url: "", // Your URL here 
    data: "" // Your data here 
    }); 

    // Redirect here 
}); 

有關更多詳細信息,請檢查此jsfiddle

2

我推薦bootbox.js(http://bootboxjs.com/)。

這是一個很好的自舉小插件,它可以實現一些非常簡單但很樸實的引導式風格模式行爲,並提供您所需要的。

該文檔也很不錯。

相關問題