插入-更新-删除 Web GUI

发布于 2024-12-11 06:20:39 字数 512 浏览 0 评论 0原文

我发现自己经常创建添加/编辑/删除/列表 GUI,以至于我厌倦了它。 一定有一些免费的软件包可以解决这个问题,对吗?

我想要的是这样的:

 {
    MyApplicationUser user = MyApplication.GetUserByID(1234);
    EditForm form = new EditForm("Title: Edit User"); //this is the magic object

    form.addFieldsFromObject(user);
 }


 function onFormSubmit(eventArgs e){
     MyApplicationUser user = form.GetSubmittedData();
     MyApplication.SaveUser(user);
 }

AddFieldsFromObject会自动创建一个html表单,其中的字段对我提供的对象的公共属性的数据类型进行数学运算。

I find myself creating Add/Edit/Delete/List GUI's so often that I'm sick and tired of it.
There must be some free package that solves this, right?

What I would like is something like this:

 {
    MyApplicationUser user = MyApplication.GetUserByID(1234);
    EditForm form = new EditForm("Title: Edit User"); //this is the magic object

    form.addFieldsFromObject(user);
 }


 function onFormSubmit(eventArgs e){
     MyApplicationUser user = form.GetSubmittedData();
     MyApplication.SaveUser(user);
 }

AddFieldsFromObject would automatically create a html form with fields mathing the datatype of the public properties of the object I feed it with.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

昨迟人 2024-12-18 06:20:39

有许多框架试图解决这个问题。 ASP.NET 动态数据可能是一个不错的起点。它使用基于模板的系统,以极少的自定义代码提供基本的 CRUD(创建、检索、更新、删除)用户界面。

ASP.NET MVC 的编辑器模型也做得非常好:

// View code
@using(Html.BeginForm(...)) {
    @Html.EditorForModel()
}

// Action code
public ActionResult ShowForm(int userId)
{
    var model = // get model from user ID;
    return View(model);
}


public ActionResult SaveForm(Model model)
{
    if(ModelState.IsValid)
    {
        // Save model
    }
}

LightSwitch 尝试通过自动生成基本脚手架代码来解决同样的问题,为您提供类似于 Microsoft Access 的体验。但由于它使用实际的 C# 代码,因此如果您发现您的需求超出了项目的原始范围,您可以更改代码以提供更多功能。

There are a number of frameworks that try to solve this problem. ASP.NET Dynamic Data may be a good place to start. It uses a template-based system to provide basic CRUD (Create, Retrieve, Update, Delete) user interfaces with very minimal custom code.

ASP.NET MVC also does a pretty good job with its editor models:

// View code
@using(Html.BeginForm(...)) {
    @Html.EditorForModel()
}

// Action code
public ActionResult ShowForm(int userId)
{
    var model = // get model from user ID;
    return View(model);
}


public ActionResult SaveForm(Model model)
{
    if(ModelState.IsValid)
    {
        // Save model
    }
}

LightSwitch tries to solve this same problem by auto-generating basic scaffolding code for you to produce an experience similar to Microsoft Access. But since it's using actual C# code, you can alter the code to provide more functionality if you find that your needs have grown beyond the original scope of the project.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文