保定网站建设解决方案广告设计公司哪家好

diannao/2026/1/18 1:58:16/文章来源:
保定网站建设解决方案,广告设计公司哪家好,新民电子网站建设哪家好,wordpress senseiABP入门系列目录——学习Abp框架之实操演练源码路径#xff1a;Github-LearningMpaAbp 这一章节将通过完善Controller、View、ViewModel#xff0c;来实现展现层的增删改查。最终实现效果如下图#xff1a; 展现层最终效果 一、定义Controller ABP对ASP.NET MVC Controlle… ABP入门系列目录——学习Abp框架之实操演练源码路径Github-LearningMpaAbp 这一章节将通过完善Controller、View、ViewModel来实现展现层的增删改查。最终实现效果如下图 展现层最终效果 一、定义Controller ABP对ASP.NET MVC Controllers进行了集成通过引入Abp.Web.Mvc命名空间创建Controller继承自AbpController 我们即可使用ABP附加给我们的以下强大功能 本地化异常处理对返回的JsonResult进行包装审计日志权限认证[AbpMvcAuthorize]特性工作单元默认未开启通过添加[UnitOfWork]开启 1创建TasksController继承自AbpController 通过构造函数注入对应用服务的依赖。 [AbpMvcAuthorize]public class TasksController : AbpController{private readonly ITaskAppService _taskAppService;private readonly IUserAppService _userAppService;public TasksController(ITaskAppService taskAppService, IUserAppService userAppService){_taskAppService taskAppService;_userAppService userAppService;} }二、创建列表展示分部视图_List.cshtml 在分部视图中我们通过循环遍历输出任务清单。 model IEnumerableLearningMpaAbp.Tasks.Dtos.TaskDto divul classlist-groupforeach (var task in Model){li classlist-group-itemdiv classbtn-group pull-rightbutton typebutton classbtn btn-info onclickeditTask(task.Id);Edit/buttonbutton typebutton classbtn btn-success onclickdeleteTask(task.Id);Delete/button/divdiv classmediaa classmedia-left href#i classfa task.GetTaskLable() fa-3x/i/adiv classmedia-bodyh4 classmedia-headingtask.Title/h4p classtext-infotask.AssignedPersonName/pspan classtext-mutedtask.CreationTime.ToString(yyyy-MM-dd HH:mm:ss)/span/div/div/li}/ul /div列表显示效果 三创建新增分部视图_CreateTask.cshtml 为了好的用户体验我们采用异步加载的方式来实现任务的创建。 1引入js文件 使用异步提交需要引入jquery.validate.unobtrusive.min.js和jquery.unobtrusive-ajax.min.js其中jquery.unobtrusive-ajax.min.js需要通过Nuget安装微软的Microsoft.jQuery.Unobtrusive.Ajax包获取。 然后通过捆绑一同引入到视图中。打开App_Start文件夹下的BundleConfig.cs添加以下代码 bundles.Add(new ScriptBundle(~/Bundles/unobtrusive/js).Include(~/Scripts/jquery.validate.unobtrusive.min.js,~/Scripts/jquery.unobtrusive-ajax.min.js));找到Views/Shared/_Layout.cshtml添加对捆绑的js引用。 Scripts.Render(~/Bundles/vendor/js/bottom) Scripts.Render(~/Bundles/js) //在此处添加下面一行代码 Scripts.Render(~/Bundles/unobtrusive/js)2创建分部视图 其中用到了Bootstrap-ModalAjax.BeginForm对此不了解的可以参考Ajax.BeginForm()知多少Bootstrap-Modal的用法介绍 该Partial View绑定CreateTaskInput模型。最终_CreateTask.cshtml代码如下 model LearningMpaAbp.Tasks.Dtos.CreateTaskInput{ViewBag.Title Create; } div classmodal fade idadd tabindex-1 roledialog aria-labelledbycreateTask data-backdropstaticdiv classmodal-dialog roledocumentdiv classmodal-contentdiv classmodal-headerbutton typebutton classclose data-dismissmodalspan aria-hiddentrue×/spanspan classsr-onlyClose/span/buttonh4 classmodal-title idmyModalLabelCreate Task/h4/divdiv classmodal-body idmodalContentusing (Ajax.BeginForm(Create, Tasks, new AjaxOptions(){UpdateTargetId taskList,InsertionMode InsertionMode.Replace,OnBegin beginPost(#add),OnSuccess hideForm(#add),OnFailure errorPost(xhr, status, error,#add)})){Html.AntiForgeryToken()div classform-horizontalh4Task/h4hr /Html.ValidationSummary(true, , new { class text-danger })div classform-groupHtml.LabelFor(model model.AssignedPersonId, AssignedPersonId, htmlAttributes: new { class control-label col-md-2 })div classcol-md-10Html.DropDownList(AssignedPersonId, null, htmlAttributes: new { class form-control })Html.ValidationMessageFor(model model.AssignedPersonId, , new { class text-danger })/div/divdiv classform-groupHtml.LabelFor(model model.Title, htmlAttributes: new { class control-label col-md-2 })div classcol-md-10Html.EditorFor(model model.Title, new { htmlAttributes new { class form-control } })Html.ValidationMessageFor(model model.Title, , new { class text-danger })/div/divdiv classform-groupHtml.LabelFor(model model.Description, htmlAttributes: new { class control-label col-md-2 })div classcol-md-10Html.EditorFor(model model.Description, new { htmlAttributes new { class form-control } })Html.ValidationMessageFor(model model.Description, , new { class text-danger })/div/divdiv classform-groupHtml.LabelFor(model model.State, htmlAttributes: new { class control-label col-md-2 })div classcol-md-10Html.EnumDropDownListFor(model model.State, htmlAttributes: new { class form-control })Html.ValidationMessageFor(model model.State, , new { class text-danger })/div/divdiv classform-groupdiv classcol-md-offset-2 col-md-10button typesubmit classbtn btn-defaultCreate/button/div/div/div}/div/div/div /div对应Controller代码 [ChildActionOnly] public PartialViewResult Create() {var userList _userAppService.GetUsers();ViewBag.AssignedPersonId new SelectList(userList.Items, Id, Name);return PartialView(_CreateTask); }[HttpPost] [ValidateAntiForgeryToken] public ActionResult Create(CreateTaskInput task) {var id _taskAppService.CreateTask(task);var input new GetTasksInput();var output _taskAppService.GetTasks(input);return PartialView(_List, output.Tasks); } 四、创建更新分部视图_EditTask.cshtml 同样该视图也采用异步更新方式也采用Bootstrap-ModalAjax.BeginForm()技术。该Partial View绑定UpdateTaskInput模型。 model LearningMpaAbp.Tasks.Dtos.UpdateTaskInput {ViewBag.Title Edit; }div classmodal fade ideditTask tabindex-1 roledialog aria-labelledbyeditTask data-backdropstaticdiv classmodal-dialog roledocumentdiv classmodal-contentdiv classmodal-headerbutton typebutton classclose data-dismissmodalspan aria-hiddentrue×/spanspan classsr-onlyClose/span/buttonh4 classmodal-title idmyModalLabelEdit Task/h4/divdiv classmodal-body idmodalContentusing (Ajax.BeginForm(Edit, Tasks, new AjaxOptions(){UpdateTargetId taskList,InsertionMode InsertionMode.Replace,OnBegin beginPost(#editTask),OnSuccess hideForm(#editTask)})){Html.AntiForgeryToken()div classform-horizontalh4Task/h4hr /Html.ValidationSummary(true, , new { class text-danger })Html.HiddenFor(model model.Id)div classform-groupHtml.LabelFor(model model.AssignedPersonId, AssignedPersonId, htmlAttributes: new { class control-label col-md-2 })div classcol-md-10Html.DropDownList(AssignedPersonId, null, htmlAttributes: new { class form-control })Html.ValidationMessageFor(model model.AssignedPersonId, , new { class text-danger })/div/divdiv classform-groupHtml.LabelFor(model model.Title, htmlAttributes: new { class control-label col-md-2 })div classcol-md-10Html.EditorFor(model model.Title, new { htmlAttributes new { class form-control } })Html.ValidationMessageFor(model model.Title, , new { class text-danger })/div/divdiv classform-groupHtml.LabelFor(model model.Description, htmlAttributes: new { class control-label col-md-2 })div classcol-md-10Html.EditorFor(model model.Description, new { htmlAttributes new { class form-control } })Html.ValidationMessageFor(model model.Description, , new { class text-danger })/div/divdiv classform-groupHtml.LabelFor(model model.State, htmlAttributes: new { class control-label col-md-2 })div classcol-md-10Html.EnumDropDownListFor(model model.State, htmlAttributes: new { class form-control })Html.ValidationMessageFor(model model.State, , new { class text-danger })/div/divdiv classform-groupdiv classcol-md-offset-2 col-md-10input typesubmit valueSave classbtn btn-default //div/div/div}/div/div/div /div script typetext/javascript//该段代码十分重要确保异步调用后jquery能正确执行验证逻辑$(function () {//allow validation framework to parse DOM$.validator.unobtrusive.parse(form);}); /script后台代码 public PartialViewResult Edit(int id) {var task _taskAppService.GetTaskById(id);var updateTaskDto AutoMapper.Mapper.MapUpdateTaskInput(task);var userList _userAppService.GetUsers();ViewBag.AssignedPersonId new SelectList(userList.Items, Id, Name, updateTaskDto.AssignedPersonId);return PartialView(_EditTask, updateTaskDto); }[HttpPost] [ValidateAntiForgeryToken] public ActionResult Edit(UpdateTaskInput updateTaskDto) {_taskAppService.UpdateTask(updateTaskDto);var input new GetTasksInput();var output _taskAppService.GetTasks(input);return PartialView(_List, output.Tasks); }五创建Index视图 在首页中我们一般会用来展示列表并通过弹出模态框的方式来进行新增更新删除。为了使用ASP.NET MVC强视图带给我们的好处模型绑定、输入校验等等我们需要创建一个ViewModel来进行模型绑定。因为Abp提倡为每个不同的应用服务提供不同的Dto进行数据交互新增对应CreateTaskInput更新对应UpdateTaskInput展示对应TaskDto。那我们创建的ViewModel就需要包含这几个模型方可在一个视图中完成多个模型的绑定。 1创建视图模型IndexViewModel namespace LearningMpaAbp.Web.Models.Tasks {public class IndexViewModel{/// summary/// 用来进行绑定列表过滤状态/// /summarypublic TaskState? SelectedTaskState { get; set; }/// summary/// 列表展示/// /summarypublic IReadOnlyListTaskDto Tasks { get; }/// summary/// 创建任务模型/// /summarypublic CreateTaskInput CreateTaskInput { get; set; }/// summary/// 更新任务模型/// /summarypublic UpdateTaskInput UpdateTaskInput { get; set; }public IndexViewModel(IReadOnlyListTaskDto items){Tasks items;}/// summary/// 用于过滤下拉框的绑定/// /summary/// returns/returnspublic ListSelectListItem GetTaskStateSelectListItems(){var listnew ListSelectListItem(){new SelectListItem(){Text AllTasks,Value ,Selected SelectedTaskStatenull}};list.AddRange(Enum.GetValues(typeof(TaskState)).CastTaskState().Select(statenew SelectListItem(){Text $TaskState_{state},Value state.ToString(),Selected stateSelectedTaskState}));return list;}} }2创建视图 Index视图通过加载Partial View的形式将列表、新增视图一次性加载进来。 using Abp.Web.Mvc.Extensions model LearningMpaAbp.Web.Models.Tasks.IndexViewModel{ViewBag.Title L(TaskList);ViewBag.ActiveMenu TaskList; //Matches with the menu name in SimpleTaskAppNavigationProvider to highlight the menu item } section scripts{Html.IncludeScript(~/Views/Tasks/index.js); } h2L(TaskList)button typebutton classbtn btn-primary data-togglemodal data-target#addCreate Task/buttona classbtn btn-primary data-togglemodal hrefUrl.Action(RemoteCreate) data-target#modal rolebuttonCreate Task使用Remote方式调用Modal进行展现/a!--任务清单按照状态过滤的下拉框--span classpull-rightHtml.DropDownListFor(model model.SelectedTaskState,Model.GetTaskStateSelectListItems(),new{class form-control select2,id TaskStateCombobox})/span /h2!--任务清单展示-- div classrow idtaskList{ Html.RenderPartial(_List, Model.Tasks); } /div!--通过初始加载页面的时候提前将创建任务模态框加载进来-- Html.Action(Create)!--编辑任务模态框通过ajax动态填充到此div中-- div idedit/div!--Remote方式弹出创建任务模态框-- div classmodal fade idmodal tabindex-1 roledialog aria-labelledbycreateTask data-backdropstaticdiv classmodal-dialog roledocumentdiv classmodal-content/div/div /div3Remote方式创建任务讲解 Remote方式就是点击按钮的时候去加载创建任务的PartialView到指定的div中。而我们代码中另一种方式是通过Html.Action(Create)的方式在加载Index的视图的作为子视图同步加载了进来。 感兴趣的同学自行查看源码不再讲解。 a classbtn btn-primary data-togglemodal hrefUrl.Action(RemoteCreate) data-target#modal rolebuttonCreate Task使用Remote方式调用Modal进行展现/a!--Remote方式弹出创建任务模态框-- div classmodal fade idmodal tabindex-1 roledialog aria-labelledbycreateTask data-backdropstaticdiv classmodal-dialog roledocumentdiv classmodal-content/div/div /div 4后台代码 public ActionResult Index(GetTasksInput input){var output _taskAppService.GetTasks(input);var model new IndexViewModel(output.Tasks){SelectedTaskState input.State};return View(model);}5js代码index.js var taskService abp.services.app.task;(function ($) {$(function () {var $taskStateCombobox $(#TaskStateCombobox);$taskStateCombobox.change(function () {getTaskList();});var $modal $(.modal);//显示modal时光标显示在第一个输入框$modal.on(shown.bs.modal,function () {$modal.find(input:not([typehidden]):first).focus();});}); })(jQuery);//异步开始提交时显示遮罩层 function beginPost(modalId) {var $modal $(modalId);abp.ui.setBusy($modal); }//异步开始提交结束后隐藏遮罩层并清空Form function hideForm(modalId) {var $modal $(modalId);var $form $modal.find(form);abp.ui.clearBusy($modal);$modal.modal(hide);//创建成功后要清空form表单$form[0].reset(); }//处理异步提交异常 function errorPost(xhr, status, error, modalId) {if (error.length0) {abp.notify.error(Something is going wrong, please retry again later!);var $modal $(modalId);abp.ui.clearBusy($modal);} }function editTask(id) {abp.ajax({url: /tasks/edit,data: { id: id },type: GET,dataType: html}).done(function (data) {$(#edit).html(data);$(#editTask).modal(show);}).fail(function (data) {abp.notify.error(Something is wrong!);}); }function deleteTask(id) {abp.message.confirm(是否删除Id为 id 的任务信息,function (isConfirmed) {if (isConfirmed) {taskService.deleteTask(id).done(function () {abp.notify.info(删除任务成功);getTaskList();});}});}function getTaskList() {var $taskStateCombobox $(#TaskStateCombobox);var url /Tasks/GetList?state $taskStateCombobox.val();abp.ajax({url: url,type: GET,dataType: html}).done(function (data) {$(#taskList).html(data);}); }js代码中处理了Ajax回调函数以及任务状态过滤下拉框更新事件编辑、删除任务代码。其中getTaskList()函数是用来异步刷新列表对应调用的GetList()Action的后台代码如下 public PartialViewResult GetList(GetTasksInput input) {var output _taskAppService.GetTasks(input);return PartialView(_List, output.Tasks); }六、总结 至此完成了任务的增删改查。展现层主要用到了Asp.net mvc的强类型视图、Bootstrap-Modal、Ajax异步提交技术。 其中需要注意的是在异步加载表单时需要添加以下js代码jquery方能进行前端验证。 script typetext/javascript$(function () {//allow validation framework to parse DOM$.validator.unobtrusive.parse(form);}); /script源码已上传至Github-LearningMpaAbp可自行参考。 作者圣杰 链接https://www.jianshu.com/p/620c20fa511b 来源简书 著作权归作者所有。商业转载请联系作者获得授权非商业转载请注明出处。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/90873.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

建设银行永泰支行网站北京工商注册网上核名

题干:某部队进行新兵队列训练,将新兵从一开始按顺序依次编号,并排成一行横队,训练的规则如下:从头开始一至二报数,凡报到二的出列,剩下的向小序号方向靠拢,再从头开始进行一至三报数…

网站的命名规则潍坊高新区建设局门户网站

1 概述 XMODEM协议是一种使用拨号调制解调器的个人计算机通信中广泛使用的异步文件运输协议。这种协议以128字节块的形式传输数据,并且每个块都使用一个校验和过程来进行错误检测。使用循环冗余校验的与XMODEM相应的一种协议称为XMODEM-CRC。还有一种是XMODEM-1K&am…

seo站长工具箱深圳外贸公司集中在哪

tar命令可以用来压缩打包单文件、多个文件、单个目录、多个目录。Linux打包命令_tartar命令可以用来压缩打包单文件、多个文件、单个目录、多个目录。常用格式:单个文件压缩打包 tar czvf my.tar.gz file1多个文件压缩打包 tar czvf my.tar.gz file1 file2,...(file…

汕尾手机网站设计奇网企业网站管理系统

1.说明:在WPF中,文件下载时需要显示下载进度,由于系统自带的条型进度条比较占用空间,改用圆形的进度条,需要在DrawingVisual上呈现。 运行的效果如图: private Point GetPointOnCir(Point CenterPoint, double r, doub…

做网站建设注册商标是多少类建设公司网站的好处

大家好,今天我们的主角是MyBatis,作为当前国内最流行的ORM框架,是我们这些crud选手最趁手的工具,赶紧来看看面试都会问哪些问题吧。基础1.说说什么是MyBatis?MyBatis logo先吹一下:Mybatis 是一个半 ORM(对…

网站功能调研方又圆网站建设

描述一下Vue.js的响应式数据绑定原理。 答案: Vue.js 使用 Observer、Compile 和 Watcher 三个组件来实现响应式数据绑定。Observer 负责监听数据对象的属性变化,Compile 负责解析模板指令并建立依赖关系,Watcher 则负责在数据变化时执行相应…

如何修改网站备案信息哪个网站做的最好

目录 1.基本概念 2.创建线程方式 2.1直接建立线程 2.2实现Runnable接口 3.3实现Callable接口 3.4 了解Future接口 Future模式主要角色及其作用 3.5实例化FutureTask类 3.实现线程安全 3.1定义 3.2不安全原因 3.3解决方案 3.4volatile与synchronized区别 4.极端情…

长春市建设工程造价管理协会网站wordpress wampserve

方法一:清空构建目录 重新设置一个新的构建目录(影子目录),或者清空当前目录的所有文件即可 方法二:修改配置文件(不推荐) 网上大部分的解决方案都是这个,直接打开找到并文件msvc…

dede中英文企业网站建设项目公告网站

在Python编程中,我们经常需要处理列表(list)。对于创建和操作这些数据结构,Python提供了很多强大的工具和语法糖,其中最引人注目的特性之一就是列表推导式(List Comprehension)。本文将深入探讨…

网站里面如何在新闻列表上显示hot微信公众平台开发商

文章目录 优先级队列的使用大堆小堆**注意** 优先级队列的模拟实现pushpopsizeemptytop 仿函数仿函数是什么pushpop 仿函数结合优先级队列的优势 优先级队列的使用 优先级队列本质是就是完全二叉树,是个堆.我们可以用优先级队列来取出一段序列中的前N个最大值. priority_queue…

温州网站建网络项目设计方案

需要对 OpenSSH 服务器和客户端进行相应配置。以下是具体步骤: 配置 OpenSSH 服务器的加密算法 1. 编辑 OpenSSH 服务器的配置文件: 打开 sshd_config 文件: sudo nano /etc/ssh/sshd_config2. 设置加密算法(Ciphers&#xff…

微信上微网站怎么做的wordpress官使用方法

文章目录 前言一、算数运算符二、赋值运算符()1.赋值运算符()2.复合赋值运算符 总结 前言 两种非常基础的运算符,看一下就懂,不需要过多的去深究细节 一、算数运算符 稍微着重看下 除法/ (不要…

申请专利的网站淘宝 网站开发 退货

学习框架&#xff0c;刚开始的时候最烦的就是一些配置文件&#xff0c;有很多需要配置的东西&#xff0c;今天把这些配置文件信息稍微整理一下&#xff0c;以后说不定会用的到。 web.xml文件 <?xml version"1.0" encoding"UTF-8"?> <web-app xm…

做电子外贸网站哈尔滨seo搜索排名优化

知识点总结 第一章&#xff1a;软件工程概述 1、软件的定义&#xff1a;在运行中能提供所希望的功能与性能的程序使程序能够正确运行的数据及其结构描述软件研制过程和方法所用的文档。 2、软件危机&#xff1a;软件开发的生产率远远不能满足客观需要。开发的软件产品往往不能…

广州网站建设推荐乐云seocms建站系统 下载

为什么80%的码农都做不了架构师&#xff1f;>>> 针对移动互联网应用的网络建设和优化 截至2013年3月,移动互联网的人均上网时长和PC互联网相比差距已经扩大了29%.PC互联网向移动端迁移的趋势进一步凸显.小米是一家专注于iPhone和Android等新一代智能手机软件…

荆州公司做网站织梦转WordPress插件

Linux零基础入门 列出文件/文件夹新建/切换路径查看当前路径重命名或者移动文件夹拷贝文件/文件夹删除文件夹设置环境变量编辑文本文件压缩和解压查看cpu的信息查看/杀死进程查看进程的CPU和内存占用重定向日志场景一场景二场景三场景四 列出文件/文件夹 命令&#xff1a;Ls(L…

爱站网关键词密度青岛新公司网站建设推广

在 js 中进行数学的运算时&#xff0c;会出现0.10.20.300000000000000004的结果&#xff0c;一开始认为是浮点数的二进制存储导致的精度问题&#xff0c;但这似乎不能很好的解释为什么在同样的存储方式下0.30.40.7可以得到正确的结果。本文主要通过浮点数的二进制存储及运算&am…

超能搜索引擎系统网站网页视频下载浏览器

源&#xff1a;STM8S和STM8L调试串口中断的注意点

如何利用网站模板做网站删除hao123主页

MessageBox.Show(); 显示消息窗口向用户展示消息。

黑山网站制作公司旅游网站建站

立即学习:https://edu.csdn.net/course/play/24458/296436?utm_sourceblogtoedu 什么是线程&#xff1f;&#xff08;以地铁为例&#xff09; 1.北京地铁、上海地铁、广州地铁称之为三个不同的进程&#xff1b;而上海1号线上海3号线称之为线程&#xff1b; 2.进程是资源单位&a…