按钮单击ASP.NET后,禁用按钮 [英] Disable button permenantely after button click ASP.NET

查看:120
本文介绍了按钮单击ASP.NET后,禁用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



请帮帮我。

我有一个webform,它有很多字段但是那里是一个单选按钮列表报告,是或否..它有按钮生成电子邮件。我想要的是当用户选择是并点击生成电子邮件时,应该生成一封电子邮件,然后按钮应该永久禁用,无论用户是否在2天后访问该页面都应该禁用该按钮。

如果用户选择否并点击电子邮件按钮,它不应该生成电子邮件,但它应该永久禁用按钮。

一如既往地期待您的合作。



谢谢



我的尝试:



我试过搜索谷歌,但之前没有报告过类似于我的例子或问题。

Hello guys,

Please help me out here.
I have a webform and it has got quite a few fields but there is one radio button list "Report" with yes or no.. and it has button generate email. What i want is when the user selects yes and clicks on generate email, an email should be generated and after that the button should get disabled permenantly no matter if the user visits the page even after 2 days the button should be disabled.
And also if the user selects no and clicks the email button it should not generate email but again it should disable the button permenantly.
Looking forward to your coorporation as always.

Thanks

What I have tried:

I have tried searching google but there is no example or problem reported previously similar to mine.

推荐答案

你好,

如果您使用数据库,则只需存储一个bool状态以检查是否单击了按钮。选择,单击按钮并在数据库表中存储True。现在,在pageload中只检查值是True还是False。如果是'True'则禁用它,否则应启用它。



从服务器端禁用按钮

btn.Enabled = false;

谢谢
Hello ,
If you are using database , then simply store one bool status to check whether button was clicked or not .Suppose ,the button was clicked and you store 'True' in database table. Now , in pageload just check whether the value was 'True' or 'False' . If it is 'True' then disable it otherwise it should be enabled .

To disabled a button from server side
btn.Enabled = false;
Thanks


您可以考虑以下方法 -

1在数据库中创建一个表,以存储电子邮件是否已发送的信息。或者您可以从上下文中插入一行包含唯一信息的行。

2.在页面加载时,点击数据库以查看是否发送了电子邮件,并相应地禁用或启用按钮。



遵循这个逻辑,如果您遇到任何问题,请告诉我,以便我们进一步指导您。



希望,它有助于:)
You may consider following approach-
1. Create a table in the database to store the information of whether the email is being already sent or not. Or you can just insert a row with unique info from the context.
2. At page load, hit database to see if the email is sent or not and accordingly disable or enable the button.

Work on this logic and if you face any problem please let me know so that I'll try to guide you further.

Hope, it helps :)


这篇关于按钮单击ASP.NET后,禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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