我在页面中使用了'n'个服务器控件.现在我正在进行性能调整,我注意到我ViewState太大了,这让我的页面变慢了.
我知道ViewStateGzip可以压缩大小.ViewState在asp.net中减少任何其他建议.我不想在IIS中执行,因为我的Web应用程序托管在共享服务器上.
我似乎无法在MVC 2 RC应用程序上进行任何客户端验证.
我的模型有以下几点:
public class ExampleModel
{
[Required(ErrorMessage="Test1 is required")]
[DisplayName("Test1")]
public string Test1 { get; set; }
[Required(ErrorMessage="Test2 is required")]
[DisplayName("Test2")]
public string Test2 { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我的观点有以下代码:
<% Html.EnableClientValidation(); %>
<%= Html.ValidationSummary(true, "Test was unsuccessful.") %>
<% using (Html.BeginForm()) { %>
<div>
<div class="editor-label">Test1:</div>
<div class="editor-field">
<%= Html.TextBoxFor(m => m.Test1) %>
<%= Html.ValidationMessageFor(m => m.Test1) %>
</div>
<div class="editor-label">Test2:</div>
<div class="editor-field">
<%= Html.TextBoxFor(m => m.Test2) %>
<%= Html.ValidationMessageFor(m => m.Test2) %>
</div>
<p>
<input type="submit" …Run Code Online (Sandbox Code Playgroud) 我在枚举助手类中有以下方法(我为了问题的目的简化了它):
static class EnumHelper
{
public enum EnumType1 : int
{
Unknown = 0,
Yes = 1,
No = 2
}
public enum EnumType2 : int
{
Unknown = 0,
Dog = 1,
Cat = 2,
Bird = 3
}
public enum EnumType3
{
Unknown,
iPhone,
Andriod,
WindowsPhone7,
Palm
}
public static EnumType1 ConvertToEnumType1(string value)
{
return (string.IsNullOrEmpty(value)) ?
EnumType1.Unknown :
(EnumType1)(Enum.Parse(typeof(EnumType1), value, true));
}
public static EnumType2 ConvertToEnumType2(string value)
{
return (string.IsNullOrEmpty(value)) ?
EnumType2.Unknown :
(EnumType2)(Enum.Parse(typeof(EnumType2), value, true));
} …Run Code Online (Sandbox Code Playgroud) 我正在寻找一个免费的.NET OCR库,它可以在给定的应用程序窗口甚至内存中的映像上进行OCR(我可以自己拍摄应用程序窗口的快照).
我看过tessnet2和MODI,但都需要一张位于磁盘上的图像.
我需要使用OCR,因为我试图编写脚本的应用程序做了一些使用Windows API无法读取的古怪的东西,我需要从屏幕上抓取数据.我已经测试了tessnet2和MODI,他们都可以阅读文本,但因为这必须在无法写入磁盘的环境中运行,我需要它能够直接从applciation窗口读取或者一些内存流的类型.
我认为OCR是我唯一的选择,但可能有其他方法,我没有想到.
建议?
根据注释进行编辑: Environment是一个没有磁盘访问权限的C#.NET Windows应用程序.它是一个应用程序,它具有动态编译和执行的代码,并且此代码在不需要除内存之外的任何资源的上下文中运行.
关于验证,
javascript和ASP.NET验证是否用于相同的目的?
如果是,您推荐哪一个?请提供一个简单的解释.
谢谢
我有一个DataSet,我想转换DataSet成List<T>
T型对象
如何转换我的DataSet?它有10列,我的对象拥有所有10个属性,它返回超过15000行.我想将该数据集返回List<obj>并循环它我该怎么做?
我正在尝试为mysql编写一个自定义的用户定义函数,所以我以http://www.mysqludf.org/index.php中的str_ucwords函数为例来构建我自己的函数.
my_bool str_ucwords_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
/* make sure user has provided exactly one string argument */
if (args->arg_count != 1 || args->arg_type[0] != STRING_RESULT || args->args[0] == NULL)
{
strcpy(message,"str_ucwords requires one string argument");
return 1;
}
/* str_ucwords() will not be returning null */
initid->maybe_null=0;
return 0;
}
char *str_ucwords(UDF_INIT *initid, UDF_ARGS *args,
char *result, unsigned long *res_length,
char *null_value, char *error)
{
int i;
int new_word = 0;
// copy the argument …Run Code Online (Sandbox Code Playgroud) 我有一个非常基本的正则表达式,我无法弄清楚为什么它不起作用所以问题是两部分.为什么我当前的版本不起作用,什么是正确的表达式.
规则很简单:
因此,以下案例应解决如下:
我正在使用的表达式是:
^%?\S{3}
Run Code Online (Sandbox Code Playgroud)
对我来说意味着:
^ - 字符串开头%? - 贪婪检查0或1%字符\S{3} - 其他3个不是空格的字符问题是,由于%?某种原因,没有进行贪婪的检查.如果它存在的话,它不会占用%字符,所以'%AB'的情况正在传递,我认为应该失败.为什么%?不吃%字符?
有人请告诉我光:)
编辑:我使用的答案是下面的Dav:^(%\S{3}|[^%\s]\S{2})
尽管这是一个2部分的答案,Alan真的让我理解为什么.我没有使用他的版本,^(?>%?)\S{3}因为它有效但不是在javascript实现中.两个伟大的答案和很多帮助.
我希望在第一次使用该程序时为用户提供使用教程的选项.我尝试在Form.Load事件中添加它,但是在弹出Messageboxes后,表单会显示出来.
这就是为什么我想知道,加载表格后是否有任何事件被解雇?
如果没有,有没有办法在加载后立即执行操作?
c# ×4
asp.net ×2
linq ×2
.net ×1
asp.net-mvc ×1
c ×1
controls ×1
dataset ×1
datatable ×1
enums ×1
events ×1
javascript ×1
load ×1
mysql ×1
ocr ×1
performance ×1
regex ×1
regex-greedy ×1
scalability ×1
scripting ×1
validation ×1
viewstate ×1
winforms ×1