Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在ASP.NET C上篡改ImageButton后,保留其原始属性#_C#_Asp.net_Webforms_Attributes_Imagebutton - Fatal编程技术网

C# 在ASP.NET C上篡改ImageButton后,保留其原始属性#

C# 在ASP.NET C上篡改ImageButton后,保留其原始属性#,c#,asp.net,webforms,attributes,imagebutton,C#,Asp.net,Webforms,Attributes,Imagebutton,我想启用一个功能,每当你点击一个imagebutton,它就会自动切换到一个加载图像,这也会禁用它,这样用户在完成它的过程之前就不能多次点击 我做了以下工作: protected void Page_Load(object sender, EventArgs e) { ibtnCancel.Attributes.Add("onclick", DisableButton(ibtnCancel)); ibtnSave.Attributes.Add("oncli

我想启用一个功能,每当你点击一个imagebutton,它就会自动切换到一个加载图像,这也会禁用它,这样用户在完成它的过程之前就不能多次点击

我做了以下工作:

protected void Page_Load(object sender, EventArgs e)
    {
        ibtnCancel.Attributes.Add("onclick", DisableButton(ibtnCancel));
        ibtnSave.Attributes.Add("onclick", DisableButton(ibtnSave));
    }


protected string DisableButton(ImageButton objImageButton)
        {
            string strAttribute = GetScript();
            strAttribute += "this.value = 'PROCESSING...';";
            strAttribute += "document.getElementById('" + objImageButton.ID + "').disabled = true;";
            strAttribute += "document.getElementById('" + objImageButton.ID + "').src = '../images/saveInactive.png';";
            strAttribute += Page.GetPostBackEventReference(objImageButton) + ";";

            return strAttribute;
        }
但是,我注意到web表单上指定的某些属性不再有效,例如:

<asp:ImageButton ID="ibtnCancel" runat="server" ImageUrl="~/images/cancelar.png" CausesValidation="False" onclick="ibtnCancel_Click" />

CausesValidation不再工作,因此这意味着,如果表单上有一个将被触发的验证器,则当我单击此按钮时,它会出现,尽管我试图告诉它不要这样做


我如何才能扭转这种局面?我可以在指定的方法上编辑任何内容吗?

请改用ImageButton的OnClientClick属性