Ho letto e riletto il codice, ma non riesco ad individuare il problema!
Ho una pagina dalla quale si selezionano degli elementi, dopodiché cliccando su Invia porta a Send.aspx, ovvero un modulo con alcuni dati da inserire per comporre una mail. Il Page Load è questo:
Al click sul pulsante, invia, viene invocato il seguente metodo:codice:protected void Page_Load(object sender, EventArgs e) { //Recupero superficie selezionata string superficieSelezionata = Request.Form["Superficie"].ToString(); string superficieRimpiazzata = superficieSelezionata.Replace("_", " "); Session["recuperoSuperficie"] = superficieRimpiazzata; lblSuperficie.Text = Session["recuperoSuperficie"].ToString(); //Recupero finestra selezionata string finestraSelezionata = Request.Form["Finestre"].ToString(); string finestraRimpiazzata = finestraSelezionata.Replace("_", " "); Session["recuperoFinestre"] = finestraRimpiazzata; lblFinestre.Text = Session["recuperoFinestre"].ToString(); //Recupero griglia selezionata string grigliaSelezionata = Request.Form["Griglia"].ToString(); string grigliaRimpiazzata = grigliaSelezionata.Replace("_", " "); Session["recuperoGriglie"] = grigliaRimpiazzata; lblGriglie.Text = Session["recuperoGriglie"].ToString(); }
Purtroppo continua a dare l'errore:codice:protected void btnSend_Click2(object sender, EventArgs e) { string nome = fname.Value.ToString(); string cognome = lname.Value.ToString(); string città = fcity.Value.ToString(); string mail = email.Value.ToString(); string telefono = phone.Value.ToString(); string larghezza = l.Value.ToString(); string altezza = h.Value.ToString(); string commenti = comment.Value.ToString(); //string installationType = Request.Form["instType"].ToString(); //string statoConsenso = Consenso.SelectedValue.ToString(); string checkConsenso = Consenso.SelectedValue; if (checkConsenso == "KO") { lblStatus.Text = "NON E' POSSIBILE PROCEDERE SENZA L'AUTORIZZAZIONE AL TRATTAMENTO DEI DATI"; } else { MailMessage message = new MailMessage(); message.To.Add("xxxxxxx@tiscali.it"); message.From = new System.Net.Mail.MailAddress("sales@xxxxxx.com"); message.Subject = "Richiesta preventivo da " + nome + " " + cognome; message.Body = "Dettagli richiesta preventivo: " + "<br>" + "<b>NOME: </b> " + nome + "<BR>" + "<b>COGNOME: </b> " + cognome + "<BR>" + "<b>CITTA': </b>" + città + "<BR>" + "<b>E-MAIL:</b> " + mail + "<BR>" + "<B>TELEFONO: </B>" + telefono + "<BR>" + "<B>LARGHEZZA:</b> " + larghezza + "<BR>" + "<B>ALTEZZA: </B>" + altezza + "<BR>" + "<b>COMMENTI:</b> " + commenti + "<BR>" + "<B>PRODOTTO:</B> "; //message.Attachments.Add(new SmtpClient smtp = new SmtpClient("localhost"); message.IsBodyHtml = true; smtp.Send(message); lblStatus.Text = "La richiesta è stata correttamente inviata."; btnSend.Enabled = false; } }
Object reference not set to an instance of an object.
StackTrace:
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
OltreLuce.Send.Page_Load(Object sender, EventArgs e) +41
System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +95
System.Web.UI.Control.LoadRecursive() +59
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678

Rispondi quotando