我需要验证 ajax get 注入的表单数据。就验证而言,直到添加新的表单元素为止,以下表单工作得很好。我正在使用 MVC 5,但相信这更多地扩展到了 jQuery 的范围。
元数据验证类:
这在形式上效果很好
public class Exer_WorkoutMetaData
{
[Required(ErrorMessage = "Name is required")]
public string Name { get; set; }
[Required(ErrorMessage = "Description is optional but testing now")]
public string Description { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为我相信我没有将 ajax get 正确绑定到视图
public partial class Exer_RoutineMetaData
{
[Required(ErrorMessage="Routing Name is Required.")]
public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
就验证而言,直到添加新的表单元素为止,以下表单工作得很好。下面是我使用的主要表格。底部是我调用来获取页面的脚本,然后调用函数来验证提交时的表单。
<div id="AjaxUpdate"></div>
<div id="showFaliure"></div>
@using (Html.BeginForm())
{
@Html.ValidationSummary(false)
<fieldset>
<legend>Workout</legend>
<div>
<table>
<tr style="justify-content:center">
<td>
Workout …Run Code Online (Sandbox Code Playgroud) 我有一个图像视图,我在屏幕的中间右侧排列.使用约束添加图像视图时,一切都很好.我需要将图像视图从原始位置(点A)动画到屏幕的底部(点B); 问题是当我尝试从A点动画到B点时,图像视图从屏幕的左上角开始,就像它只是简单地添加没有约束(而不是我希望它在中央) .
这是代码和一些评论:
#define DEGREES_TO_RADIANS(x) (M_PI * x / 180.0) //defined above
- (void)viewDidLoad
{
UIImage *cardFaceDownImage = [UIImage imageNamed:@"b-top@2x.png"];
UIImageView *dealCardDown = [[UIImageView alloc] initWithImage:cardFaceDownImage];
dealCardDown.translatesAutoresizingMaskIntoConstraints = NO;
NSLayoutConstraint *dealCardConstraintY = [NSLayoutConstraint constraintWithItem:dealCardDown attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterY multiplier:1 constant:1];
NSLayoutConstraint *dealCardConstraintX = [NSLayoutConstraint constraintWithItem:dealCardDown attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1 constant:130];
[self.view addConstraint:dealCardConstraintY];
[self.view addConstraint:dealCardConstraintX];
[self.view addSubview:dealCardDown];
//IF I comment out the below code the UIImageView lines up where I want it (Point A)
//IF I don't coment it …Run Code Online (Sandbox Code Playgroud)