Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy I am getting this error with the Mail function when clicked on the Finished button in the Wizard?
    primarykey
    data
    text
    <p>I was using an ASP.NET Wizard control for adding news users to the web-based application that I developed. Everything works well and fine. Now, I got a new requirement from the Admin of the system which is sending an email notification to the new user telling him that he has been added to the system. I added the Mail function to my code and it works, however, in the IE browser I noticed the error icon at the left bottom corner and I don't know why. </p> <pre><code>Problems with the Web page might prevent it from being displayed properly or functioning properly.... Line: 74 Char: 7 Error: Object Expected Code: 0 </code></pre> <p><strong>So How to remove this error?</strong></p> <p><strong>Code-Behind with Mail function:</strong></p> <pre><code> protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e) { //If one of the items is selected AND a username exists in the Username session object update the user role string username = TextBox1.Text; if (!String.IsNullOrEmpty(radio1.SelectedValue) &amp;&amp; !String.IsNullOrEmpty(username)) { string connString = "Data Source=localhost;Initial Catalog=TestDB;Integrated Security=True"; string insertUserCommand = "INSERT INTO employee (Name, Username, JobTitle, BadgeNo, EmpOrgType, DivisionCode) values (@Name, @Username, @JobTitle, @BadgeNo, @EmpOrgType, @DivisionCode)"; string cmdText = "SELECT Count(*) FROM employee WHERE Username = '" + username + "'"; using (SqlConnection conn = new SqlConnection(connString)) { conn.Open(); // Open DB connection. using (SqlCommand cmd = new SqlCommand(cmdText, conn)) { if ((int)cmd.ExecuteScalar() == 0){ ......................................... } } } //For updating the role of the user string deleteCommand = "DELETE FROM UserRole where Username=@Username"; string insertCommand = "INSERT INTO UserRole (RoleID,Username) values(@RoleID,@Username)"; using (SqlConnection conn = new SqlConnection(connString)) { conn.Open(); //using (SqlCommand cmd = new SqlCommand(cmdText, conn)) using (SqlCommand cmd = new SqlCommand(deleteCommand, conn)) { cmd.Parameters.AddWithValue("@Username", username); cmd.ExecuteNonQuery(); //Now the insert cmd.CommandText = insertCommand; cmd.Parameters.Clear(); //need this because still has params from del comm cmd.Parameters.AddWithValue("@RoleID", radio1.SelectedValue); cmd.Parameters.AddWithValue("@Username", username); cmd.ExecuteNonQuery(); //infoSpan.InnerText = String.Format("The users role has been updated to - {0}", radio1.SelectedValue); //cmd.ExecuteScalar(); //infoSpan.InnerText = String.Format("The users role has been updated to - {0}", radio1.SelectedValue); } } Wizard1.Visible = false; wizard.InnerHtml = "..............."; } Send(username); } /*****************************************************/ /*For sending an email */ protected void Send(string toAddresses, string fromAddress, string MailSubject, string MessageBody, bool isBodyHtml) { SmtpClient sc = new SmtpClient("MailAddress"); try { MailMessage msg = new MailMessage(); msg.From = new MailAddress("test@mailAddress.com", "Test Sys."); msg.Bcc.Add(toAddresses); msg.Subject = MailSubject; msg.Body = MessageBody; msg.IsBodyHtml = isBodyHtml; sc.Send(msg); } catch (Exception ex) { throw ex; } } protected void SendEmailToUser(string username) { string connString = "Data Source=localhost;Initial Catalog=TestDB;Integrated Security=True"; string networkID = username.ToString(); using (SqlConnection conn = new SqlConnection(connString)) { var sbEmailAddresses = new System.Text.StringBuilder(2000); //initiate the varibles that will be retreived from the database string name = null; // Open DB connection. conn.Open(); string cmdText2 = @"SELECT Name FROM dbo.employee WHERE (Username = @networkID)"; using (SqlCommand cmd = new SqlCommand(cmdText2, conn)) { cmd.Parameters.AddWithValue("@networkID", networkID); SqlDataReader reader = cmd.ExecuteReader(); if (reader != null) { if (reader.Read()) { name = reader["Name"].ToString(); sbEmailAddresses.Append(username).Append("@mailAddress.com"); } } //var sEMailAddresses = sbEmailAddresses.ToString(); string body = ".........................."; Send(sbEmailAddresses.ToString(), "", "Welcome", body, true); sbEmailAddresses.Clear(); } conn.Close(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload