locked
Alert in Response.Write RRS feed

  • Question

  • Hi All,

    I am using following line to alert the message. But , I am not getting any alert. Can any one help ?

     Response.Write("<script language=javascript>alert(" +'"' + toEmail.ToString() +'"' +"); </script>");

    Thanks

    Wednesday, August 29, 2012 3:30 PM

All replies

  • Where are you putting this line of code?

    Jason Warren
    Infrastructure Architect

    Wednesday, August 29, 2012 4:00 PM
  •  

    I am using that line below code...

    if (Page.IsValid)
                {
                    string subject = "welcome";
                    string body = name + ": " + SPEncode.HtmlEncode(TxtBxNaam.Text) + "<br/>";
                    body += middleName + ": " + SPEncode.HtmlEncode(TxtBxMiddleName.Text) + "<br/>";
                    body += lastName + ": " + SPEncode.HtmlEncode(TxtBxVoornaam.Text) + "<br/>";
                    body += birth + ": " + String.Format("{0}/{1}/{2}", TxtBxMonth.Text, TxtBxDate.Text, TxtBxYear.Text) + "<br/>";
                    body += telephone + ": " + TxtBxTelephone.Text + "<br/>";
                    body += address + ": " + SPEncode.HtmlEncode(TxtBxAdres.Text) + "<br/>";
                    body += radio1 + ":" + (this.radioButton1.Checked == true ? "true" : "false");


                    SPSecurity.RunWithElevatedPrivileges(delegate
                    {
                        string siteUrl = SPContext.Current.Site.Url;
                        using (SPSite site = new SPSite(siteUrl))
                        {
                            using (SPWeb web = site.OpenWeb())
                            {
                                SPUtility.SendEmail(web, false, false, toEmail, subject, body);
                                Response.Write("<script language=javascript>alert(" +'"' + toEmail.ToString() +'"' +"); </script>");
                            }
                        }
                    });

                    Response.Redirect(this.confirmation);
                }

                   
    Thursday, August 30, 2012 3:38 AM
  • Hi,

    Try this:

    Response.Write(@"<script language='javascript'>alert('" + toEmail.ToString() + "');</script>");
    Let us know if you have any problem


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"

    Thursday, August 30, 2012 5:08 AM
    Moderator
  • Hi Hemendra,

    I've tried with the above mentioned. I'm not getting any alert.

    I've debugged the solution , the value is passing to "toEmail" parameter. But, alert is not coming.

    I need to confirm whether the mail going or not with "toEmail" value.

    Please let me know any other way to confirm the mail is going or not with the "toEmail" value.

    Thanks

    Thursday, August 30, 2012 7:33 AM
  • Hi,

    Just try this:

    http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/3a76cb61-f29e-4d0d-b416-cc0f0d80f4e0/

    Let us know your result


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"

    Thursday, August 30, 2012 7:55 AM
    Moderator