禁用按钮或在单击按钮时显示所需的验证 [英] disabling a button or showing required validations on button click

查看:90
本文介绍了禁用按钮或在单击按钮时显示所需的验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,

我有一个提交按钮,我想对其进行验证,以便在数据表中没有要提交的数据时它不会显示异常,并且可能显示警告或消息,例如"请选择一个项目!". .

还想知道如何禁用按钮.

谢谢
Amit

Hey there,

I have a submit button and I want to validate it so that it does not show exception when there is no data to submit in the data table and maybe show an alert or message like "please select an item!".

Also want to know how can I disable a button.

Thanks
Amit

推荐答案

此答案用于禁用按钮

您可以将图像和按钮保留在相同的div标签中.首先,将
按钮可见,图像不可见.当用户单击按钮时
然后隐藏按钮并使图像可见.因此,在这种情况下,用户
将无法两次单击该按钮,您的问题将得到解决.
This answer is for disable a button

You can keep a image and the button in the same div tag. Initially, make the
button visible and the image invisible. And when the user clicks the button
then hide the button and make the image visible. So in this situation user
will not be able to click the button twice and your problem will get solved.


例如,假设您的按钮ID为btnSubmit
并且数据表的名称为dtTestTable,则后面代码中的代码将为
say for example your button id is btnSubmit
and the name of the datatable is dtTestTable then the code in the code behind will be
if(dtTestTable != null )
{
  btnSubmit.CausesValidation = false; 
}
else
{
  btnSubmit.CausesValidation = true;
}



干杯... :)
如果这可以解决您的问题,请将其标记为已回答



cheers... :)
if this solves your problem mark it as answered


您好,

本文可能会有所帮助.

禁用使用AJAX加载背景图片的PostBack期间的ASP.NET按钮 [
hello,

This article might help.

Disable an ASP.NET button during PostBack with AJAX loading background image[^]


这篇关于禁用按钮或在单击按钮时显示所需的验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆