在我的ASP.NET MVC 4应用程序中,我试图使用Fluent Validation进行不显眼的客户端验证.
<script src="/Scripts/jquery.validate.min.js" type="text/javascript">
</script>
<script src="/Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript">
</script>
Run Code Online (Sandbox Code Playgroud)
我在创建新的ASP.NET MVC 4应用程序时提供了VS2010提供的这两个.js文件.我还在我的web.config文件上启用了客户端验证.
<appSettings>
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)
据我所知,当启用客户端验证和不引人注目的JavaScript时,带有客户端验证规则的输入字段包含data-val ="true"属性,以触发不显眼的客户端验证.我在输入字段中有这些字段.
例如,
<input class="input-validation-error" data-val="true" data-val-
required="error text here" id="purchasePrice"
name="PurchasePrice" type="text" value="">
<span class="field-validation-error error" data-valmsg-for="PurchasePrice"
data-valmsg-replace="true">'Purchase Price' must not be empty.</span>
Run Code Online (Sandbox Code Playgroud)
但是,当我提交表单时,它会发布到控制器,我的模型会在我的控制器代码而不是客户端上进行检查.
编辑:
这是我的表格开头标签.
@using (Html.BeginForm("Create", "Product", FormMethod.Post,
new { enctype = "multipart/form-data", @class = "mainForm",
@id = "productCreateForm" }))
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?谢谢.
我想在我的Web应用程序中的代码隐藏文件中创建一个Text文件.但是,我不允许将此文件保存到服务器.所以我尝试使用MemoryStream类将我的文件保存到内存中.到目前为止,我有,
MemoryStream memoryStream = new MemoryStream();
TextWriter textWriter = new StreamWriter(memoryStream);
textWriter.WriteLine("Something");
memoryStream.Close();
Run Code Online (Sandbox Code Playgroud)
它似乎工作但我的要求是当他/她点击按钮时在客户端浏览器上打开此文件.由于此文件没有像..../text.txt这样的物理路径.我不知道如何在浏览器上打开它.
如何使用C#在ASP.Net中执行此操作.我搜索了很多,但找不到适合我的解决方案.
提前致谢.
我正在练习教科书中的练习,但是我无法得到我应该得到的输出.
这是我有的:
#include <math.h>
#include <GLUT/glut.h>
#include <OpenGL/OpenGL.h>
//Initialize OpenGL
void init(void) {
glClearColor(0.0,0.0,0.0,0.0);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0.0,300.0,0.0,300.0);
}
void drawLines(void) {
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0,0.4,0.2);
glPointSize(3.0);
glBegin(GL_LINES);
glVertex2d(180, 15);
glVertex2d(10, 145);
glEnd();
}
int main(int argc, char**argv) {
glutInit(&argc, argv);
glutInitWindowPosition(10,10);
glutInitWindowSize(500,500);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutCreateWindow("Example");
init();
glutDisplayFunc(drawLines);
glutMainLoop();
}
Run Code Online (Sandbox Code Playgroud)
当我运行这段代码时,我得到了完全空白的白色屏幕.
我试图使用ASP.NET MVC项目的流畅验证.我正在尝试验证我的视图模型.
这是我的viewmodel,
[Validator(typeof(ProductCreateValidator))]
public class ProductCreate
{
public string ProductCategory { get; set; }
public string ProductName { get; set; }
....
}
Run Code Online (Sandbox Code Playgroud)
这是我的验证员班,
public class ProductCreateValidator : AbstractValidator<ProductCreate>
{
public ProductCreateValidator()
{
RuleFor(product => product.ProductCategory).NotNull();
RuleFor(product => product.ProductName).NotNull();
}
}
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,我正在检查我的ModelState是否有效,
[HttpPost]
public ActionResult Create(ProductCreate model)
{
/* This is a method in viewmodel that fills dropdownlists from db */
model.FillDropDownLists();
/* Here this is always valid */
if (ModelState.IsValid)
{
SaveProduct(model);
return RedirectToAction("Index");
}
// If we …Run Code Online (Sandbox Code Playgroud) 我知道之前会询问此问题,但Azure状态仪表板显示所有服务正在按预期运行.但是,我的所有网站都标记为有限.我可以达到其中一个但不能达到其他3.为了测试这个问题,我在azure上创建了一个新的网站,其状态设置为Running.我的网站位于Europe West服务器.
这是我的应用程序中断问题还是出了什么问题?
当我使用 @Html.Action("Index")的InsufficientExecutionStackException就是扔了,为什么呢?这是一个简单的mvc命令行.
我有一个List对象,它包含School.Id,School.Name和School.Address.
我需要在selectOneMenu列表框中列出所有School.Name.Java代码和相应的JSF代码将如何.
到目前为止我的工作;
<h:selectOneMenu value="#{School.listschoolName}">
<f:selectItems value="#{School.listschoolName}" />
</h:selectOneMenu>
Run Code Online (Sandbox Code Playgroud)
Java类
//And also i got the corresponding getters and setters for these
private List<School> listschool;
public void listschoolName(){
setListschool(hml.findAllSchool());
}
Run Code Online (Sandbox Code Playgroud)
该findAllSchool()方法实际上返回一个List<School>对象.
我需要在列表框中显示这些学校名称(dropdown/selectOneMenu).我怎样才能做到这一点 ?
当我尝试执行时:
#!/usr/bin/env ruby
class WrongNumberOfPlayersError < StandartError ; end
class NoSuchStrategyError < StandartError ; end
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
`<main>': uninitialized constant StandartError (NameError)
Run Code Online (Sandbox Code Playgroud)
我假设我需要StandartError文件,所以我写道
require 'StandartError'
Run Code Online (Sandbox Code Playgroud)
就在我指定我的Ruby目录之后.结果我遇到以下错误:
/Users/nevayeshirazi/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- StandartError (LoadError)
from /Users/nevayeshirazi/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from ./part2.rb:2:in `<main>'
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么 ?任何帮助真的很感激.
我有以下Action方法,它使用Scanner类使用一些webservice来获取一些数据.当我在GetSuggestions方法中使用断点时,我可以看到结果.但是,此数据永远不会返回到我的Action方法.相反,当我检查model内部的值时Index(),它是,
Id = 1, Status = System.Threading.Tasks.TaskStatus.WaitingForActivation, Method = "{null}", Result = "{Not yet computed}"
Run Code Online (Sandbox Code Playgroud)
我检查了这个问题,但它没有帮助我.
控制器动作方法:
[HttpGet]
public ActionResult Index()
{
var plane = new Scanner();
var model = plane.GetSuggestions("ISTANBUL");
return View(model);
}
Run Code Online (Sandbox Code Playgroud)
GetSuggestions方法:
public async Task<List<PlaceDto>> GetSuggestions(string key)
{
string url = String.Format("URL GOES HERE", key, API_KEY);
string data = await RequestProvider.Get(url);
return JObject.Parse(data).SelectToken("Places").ToObject<List<PlaceDto>>();
}
Run Code Online (Sandbox Code Playgroud)
RequestProvider方法:
public static async Task<string> Get(string url)
{
using (var client = new …Run Code Online (Sandbox Code Playgroud) 我试图访问一个对象数组的成员,这可能吗?
我已经声明了一个名为Particle的结构,并初始化了一个约为40个粒子的"粒子"对象数组,现在我需要访问每个粒子,例如:particle.Gbest任何人都可以帮忙吗?
这是我的代码:
struct particle
{
double[] position = new double[100];
double Gbest, Lbest;
double Pconst = 0.5;
}
object[] swarm = new object[swarm_size];
for (int i = 0; i < swarm_size; i++)
{
swarm[i] = new particle();
}
Run Code Online (Sandbox Code Playgroud) asp.net-mvc ×4
c# ×4
asp.net ×2
.net ×1
async-await ×1
azure ×1
glassfish-3 ×1
glut ×1
java ×1
jsf ×1
line ×1
memorystream ×1
netbeans ×1
opengl ×1
razor ×1
require ×1
ruby ×1
viewmodel ×1