在asp.net中禁用CheckBox [英] CheckBox disabled in asp.net

查看:80
本文介绍了在asp.net中禁用CheckBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在asp.net中发送邮件。管理员发送邮件到相应的电子邮件ID然后管理员检查复选框并发送电子邮件,此后我想显示复选框禁用这是我想要的,因为当管理员再次登录然后他将无法再次检查相同的复选框因为邮件已经发送,当新邮件到来时,必须启用复选框,因为管理员仍然没有在新邮件中执行任何检查......



在我的项目中......我签入复选框,然后单击提交按钮,然后发送电子邮件发送,但当管理员再次登录,然后检查新记录是否来,然后上一个复选框始终启用但我希望在以前的记录中禁用复选框,因为电子邮件已发送..



喜欢这个





i am trying to sending mail in asp.net . when admin send mail to respective email id then admin check the check boxes and send the email, after this i want to show check box disabled this is what i want because when admin again login then he will not able to check again in same check boxes because mail already sent and when new email come then check box must be enable because admin still not perform any check in new email ...

In my project..when i check in check boxes and click on submit button then email send but when admin again login and then check whether new record comes or not then previous check box always enabled but i want disabled check boxes in previous record because email already send ..

like this


emalid
john_11@gmail.com   (this is new record then  check box enabled)
kety_45@yahoo.com  ( admin already check in this and mail  send then check box must be
 disabled)





这里是代码按钮代码





here is code button code

protected void btnSendMail_Click(object sender, EventArgs e)
          {
           string connStr =
           ConfigurationManager.ConnectionStrings["email"].ConnectionString;
           SqlConnection mySQLconnection = new SqlConnection(connStr);
           string empId = string.Empty;
           DataTable dt = new DataTable();
           try
           {
           mySQLconnection.Open();
           for (int i = 0; i < Repeateremail.Items.Count; i++)
           {
            CheckBox checkboc =
          ((CheckBox)Repeateremail.Items[i].FindControl("chkSelect"));
            if (checkboc != null)
            {

                if (checkboc.Checked == true)
                {
                    string emailId =
               ((Label)Repeateremail.Items[i].FindControl("lbl_email")).Text;

                    SendEmailUsingGmail(emailId);
                    dt.Clear();
                    dt.Dispose();
                }
            }
        }


    }

推荐答案

嗨Ayesha,



对于你的问题,我想提出一个想法。

你需要加一个更多列,例如表中的 IsMailSent int。

如果管理员向该emailid发送电子邮件,则将IsMailSent列更改为 1 否则 0

当管理员再次登录时,尝试检查字段,并根据启用/禁用页面中的复选框。

表应该像



emailid isEMailSent

john_11@gmail.com 1

kety_45@yahoo.com 0

test@test.com 0



现在加载管理页面检查isEmailSent字段,如果它的0然后启用其他复选框e禁用它。

成功发送邮件后,您可以将值更改为1,以便将电子邮件发送到该特定电子邮件ID。

希望这对您有所帮助。



问候,

RK
Hi Ayesha,

For your problem, I would like to suggest one idea.
You need to add one more column like "IsMailSent" int in your table.
If admin sends an email to that emailid then change IsMailSent column to 1 otherwise 0.
And when admin logins again try to check the field and according to that enable/disable the checkbox in your page.
Table should be like

emailid isEMailSent
john_11@gmail.com 1
kety_45@yahoo.com 0
test@test.com 0

now while loading admin page check for isEmailSent field and if its 0 then enable the checkbox otherwise disable it.
After sending mail successfully you can change the value to 1 to mention that email is sent to that particular email id.
Hope this helps you a bit.

Regards,
RK


我会通过javascript设置a控制已选中/未选中状态boolean true / false基于你在构建页面时发生的事情(在发送之后),当你收到一条消息时你把它恢复为真。



否则你需要收到电子邮件时的回发。
I would control the checked/unchecked state through javascript set a boolean true/false based on what happens when you build the page (after sent eg) when receiving a message you put it back to true.

Otherwise you'll need a postback when an email is received.


这篇关于在asp.net中禁用CheckBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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