0

我必须添加一个按钮,单击该按钮会创建一个新的文本框,我可以在其中添加一些文本并将其保存在数据库中。

例如-我三次单击按钮,它将在数据库中创建 3 个文本框和 3 个新列以保存它们。

应用程序位于 ASP.NET MVC 3 和 Entity Framework 4.3.1 中。是否可以使用 EF 映射到静态类来做到这一点?

4

1 回答 1

0
    You can achieve this by following steps:
    //View page
    1)Write a function which creates a textbox and render in div.
    Something like this:

    <input id="btnAdd" type="button" value="Add" />
    <div id="TextBoxContainer">
    //Area of textboxes
    </div>
    <br />


    $(function () {
        $("#btnAdd").bind("click", function () {
            var div = $("<div />");
            div.html(GetTextBox(""));
            $("#TextBoxContainer").append(div);
        });

    });
    function GetTextBox(value) {
        return '<input name = "TextBox" type="text" />'
    }


    //Server side code
    Write an event handler on button click which adds three columns in the database.  
This could be done either by writing stored procedure or create statement. 
于 2015-05-29T06:43:45.000 回答