C# 为什么单击向导中的“完成”按钮时邮件功能会出现此错误?

C# 为什么单击向导中的“完成”按钮时邮件功能会出现此错误?,c#,asp.net,sql-server-2008-r2,C#,Asp.net,Sql Server 2008 R2,我使用ASP.NET向导控件将新闻用户添加到我开发的基于web的应用程序中。一切都很好。现在,我从系统管理员那里得到了一个新的要求,即向新用户发送电子邮件通知,告知他已添加到系统中。我在我的代码中添加了邮件功能,它可以正常工作。然而,在IE浏览器中,我注意到左下角的错误图标,我不知道为什么 Problems with the Web page might prevent it from being displayed properly or functioning properly.... Li

我使用ASP.NET向导控件将新闻用户添加到我开发的基于web的应用程序中。一切都很好。现在,我从系统管理员那里得到了一个新的要求,即向新用户发送电子邮件通知,告知他已添加到系统中。我在我的代码中添加了邮件功能,它可以正常工作。然而,在IE浏览器中,我注意到左下角的错误图标,我不知道为什么

Problems with the Web page might prevent it from being displayed properly or functioning properly....
Line: 74
Char: 7
Error: Object Expected
Code: 0
那么如何删除此错误?

带有邮件功能的代码隐藏:

 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) && !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();
        }
    }

尝试以下步骤:

Internet Explorer中打开工具菜单
,然后选择
Internet选项
。在“生成的Internet选项”对话框的“高级”页面上,找到并选择“禁用脚本调试(Internet Explorer)选项”

另外,找到并取消选择
“显示关于每个脚本错误的通知”
选项。单击“确定”保存更改。重新启动Internet Explorer