简体   繁体   English

单击 asp.net mvc 或 jquery 中的按钮时如何创建新表单?

[英]How to create new form when clicking button in asp.net mvc or jquery?

I have a card and what i want to do, is when a user click(create course) button it must generate new content(asp.net mvc) or dashboard that is empty.我有一张卡片,我想做的是,当用户单击(创建课程)按钮时,它必须生成新的内容(asp.net mvc)或为空的仪表板。 I have some ideas around this.我对此有一些想法。 Let me share below;让我在下面分享;

<div class="row">
    <div class="col-xs-3 ml-auto">
        <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
            Start New Course
        </button>
    </div>
</div>


<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">Start New Course</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="form-group">
                <label for="CourseName" class="col-sm-2 col-form-label">CourseName:</label>
                <div class="col-sm-6">
                    @Html.EditorFor(model => model.CourseName, new { htmlAttributes = new { @class = "form-control", autofocus = "autofocus", placeholder = "CourseName" } })

                </div>


            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
                <button type="button" class="btn btn-primary">Create Course</button>
            </div>
        </div>
    </div>
</div>

// Jquery
<a class="btn btn-large btn-success" id="fire" href="/Controller/Courses.chtml#">Create Courses</a>

$('#fire').on('click', function (e) {

     // dont know what to put here....?

})

I dont know if my logic is wrong and need some ideas around.我不知道我的逻辑是否错误,需要一些想法。 Meaning what i want when i click the create button from the modal form it must take me to the new content(asp.net mvc).这意味着当我从模态表单中单击创建按钮时我想要什么,它必须将我带到新内容(asp.net mvc)。 Something along this line沿着这条线的东西

Change the href value, replace the ActionResultName and ControllerName, see below:更改href值,替换ActionResultName和ControllerName,见下图:

<a class="btn btn-large btn-success" id="fire" href="@Url.Action("ActionResultName","ControllerName")">Create Courses</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM