我正在开发一个复杂的业务应用程序,其中将有一个数据访问层.截至目前,我们有两个选择 - 要么创建我们自己的自定义数据访问层,要么使用Microsoft内置库.我正在寻找一些基本的理由来选择其中一种.
任何回复将受到高度赞赏.
我的问题是,我有一个简单的Web表单,其中包含两个文本框和一个按钮.页面上有一些asp.net验证器控件.所以我希望客户端在完成所有验证后禁用按钮.并且在禁用按钮后也是如此,我正在执行一些服务器端代码.所有这一切工作正常,但是,如果我设置按钮的回发网址,它会失败.bellow是编码的一部分,可以给你一些简短的想法.任何提示都将受到高度赞赏.......
我想在复合控件中实现此功能.这是按钮类
public class MyButton : Button
{
protected override void OnPreRender(EventArgs e)
{
if (this.CausesValidation)
{
if (!String.IsNullOrEmpty(this.ValidationGroup))
{
this.Attributes.Add("onclick", @"javascript:
if (typeof(Page_ClientValidate) == 'function')
{
if (Page_ClientValidate('" + this.ValidationGroup + "')){" + this.ClientID + ".disabled=true;" + Page.GetPostBackEventReference(this) +
"}else{return;}} else{" + this.ClientID + ".disabled=true;" + Page.GetPostBackEventReference(this) + "}");
}
else
{
this.Attributes.Add("onclick", @"javascript:
if (typeof(Page_ClientValidate) == 'function')
{
if (Page_ClientValidate()){" + this.ClientID + ".disabled=true;" + Page.GetPostBackEventReference(this) +
"}else{return;}} else{" + this.ClientID + ".disabled=true;" + Page.GetPostBackEventReference(this) + "}");
} …Run Code Online (Sandbox Code Playgroud)