Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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


SQL
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

C#
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();
                }
            }
        }


    }
Posted
Comments
saad_lah 13-Nov-13 2:12am    
you are the same who posted over stackoverflow :D
Diya Ayesa 13-Nov-13 2:38am    
haha ...yes :P how did u got it?
saad_lah 13-Nov-13 2:54am    
nah! just a co-incidence while checking questions :P
Diya Ayesa 13-Nov-13 3:41am    
ahhha ..:P

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
 
Share this answer
 
v2
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.
 
Share this answer
 
Comments
Diya Ayesa 13-Nov-13 7:44am    
how?
V. 13-Nov-13 7:53am    
each server control gets a client id when the page is built. I even think this is a property (ClientID or something) With that clientid you can use javascript to manipulate the control, in case of a checkbox: document.getElementById("mycliendid").checked = true; //or false

I propose to startup a small prototype project to get the hang of how to let server side and client side "work together".

The rest of the business logic is up to you, I don't know the specifications of your project.
Diya Ayesa 13-Nov-13 13:57pm    
THERE IS ONLY ONE CHECK BOX IN EACH ROW
V. 14-Nov-13 2:21am    
That has nothing to do with it. Each control has a client id, if none is assigned, asp.net will assign one. Open the web page and do a view source to see for yourself. As I said before, if you have never done so before, start a prototype test project. First set a checkbox to see how it works (client/server side code), then move on to a more complex situation similar to what you have here. Then you can incorperate that solution into this one.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900