Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Aiuto per Form!!!

  1. #1

    Aiuto per Form!!!

    Il mio primo Form. vi prego qualcuno mi aiuti!
    Ci sono tre campi: Nome, Mail, Commento,dopo aver spedito la mail nessuno dei tre viene visualizzato. E appena cliccato il tasto invia...si apre la finestra del browser di posta!
    Come posso fare?
    Non penso sia poi così difficile! Ma non ne vengo a capo...!!!

  2. #2
    :master:
    Se non ho capito male ti serve qualcosa come quanto segue :
    (
    Il codice lo trovi anche allegato spero...
    Rinominare da ".gif" in ".aspx"
    Ed ovviamente ignorare ed eliminare i primi caratteri
    cioe' "GIF89a$"
    )

    codice:
    <%@Page Language="C#"  Debug="true"%>
    
    <%@ Import Namespace="System" %>
    <%@ Import Namespace="System.Web.Mail" %>
    
    
    <script language="C#" runat="server">
    
      void Page_Load (Object sender, EventArgs e)
       {
    	if (IsPostBack)
    	 {
    	  Messaggio.InnerHtml = "<font color=\"red\" style=\"font: 8pt verdana;\">Note : All fields are required!</font></br>"; 
    	 }
    	 
       }
    
      void doSend (Object sender, EventArgs e)
       {
    	if ((frmName.Text != "") && (frmEmail.Text != "") && (frmComment.Text != ""))
    	 {
    	  try
    	   {
    		string body = "";
    		MailMessage mail = new MailMessage();
    
    		body  = frmComment.Text.Replace("'", "''").Replace("\"", "\"");
    		body += "\n\n______________________________________________________________________________________";
    		body += "\nMittente : " + frmName.Text;
    		body += "\n   Email : " + frmEmail.Text;
    		body += "\n      IP : " + Request.ServerVariables["REMOTE_ADDR"].ToString();
    		body += "\n    Time : " + DateTime.Now.ToString();
    		body += "\n\n______________________________________________________________________________________";
    
    	    mail.To = "tuaemail@dominio.ext"; // qui configuri l'email di chi dovra' ricevere il messaggio con il commento
    		mail.From = frmEmail.Text;
    		mail.Subject = "Information request by " + frmName.Text + ".";
    		mail.Body = body;
    //		mail.BodyFormat = MailFormat.Html;
            mail.Priority = MailPriority.High;
    	    SmtpMail.SmtpServer = "localhost"; // o tuo smtp che non richiede autenticazione es. smtp.tiscali.it
    		SmtpMail.Send(mail);
    
    		Messaggio.InnerHtml = "</br>Tutto Ok!</br>";
    	   }
    	  catch (Exception ex)
    	   {
    	    Messaggio.InnerHtml = "<font color=\"white\">Exception : " + ex.ToString().Replace("\r\n", "</br>") + "</font>";
    	   }
    	 }
    	else
         {
    	  Messaggio.InnerHtml = "<font color=\"red\" style=\"font: 8pt verdana;\">Note : All fields are required!</font></br>"; 
          Response.Redirect(Request.Url.ToString());
    	 }
       }
    </script>
    
    <html>
     <head>
      <title>Contact Form.</title>
     </head>
     <style>
      body{
        position: Static !important;
         padding: 0px 0px !important;
    	   width: 800px !important;
     	  height: 600px !important;
    	  margin: Auto !important;
      background: #20A0A0 !important; 
           color: Black !important;
    	  }
    	 a{
    	          color: Blue;
    	text-decoration: None;
    	  }
    	 a:active{
    	          color: Blue;
    	text-decoration: None;
    	  }
    	 a:visited{
    	          color: Blue;
    	text-decoration: None;
    	  }
    	 a:hover{
    	          color: LightBlue;
    	text-decoration: None;
    	  }
      </style>
     <body>
      <div align="center">
       <form method="post" runat="server">
     	 <asp:TextBox id="frmName" Columns="86" Value="Insert your Name Here!" runat="server"/>
    	 <asp:RequiredFieldValidator id="vldfrmName" ControlToValidate="frmName" ErrorMessage="Name is Required" display="dynamic" runat="server"> Required!</asp:RequiredFieldValidator></br>
    
    	 <asp:TextBox id="frmEmail" Columns="86" Value="Insert your Em@il here!" runat="server"/>
    	 <asp:RegularExpressionValidator id="vldfrmEmail" ControlToValidate="frmEmail" ValidationExpression="(\w+|\W+)([-+.](\w+|\W+))*@(\w+|\W+)([-.](\w+|\W+))*\.(\w+|\W+)([-.](\w+|\W+))*" ErrorMessage="A valid Email address is Required!" display="dynamic" runat="server">A valid Email address is Required!</asp:RegularExpressionValidator></br>
    	 
    	 <asp:TextBox id="frmComment" Rows="24" Columns="65" TextMode="MultiLine" runat="server"/></br>
    	 <asp:RequiredFieldValidator id="vldfrmComment" ControlToValidate="frmComment" ErrorMessage="A comment is Required!" display="dynamic" runat="server" > Required!</asp:RequiredFieldValidator>
        <p align="center">
    	 <asp:Button id="Button" text="Send" OnClick="doSend" runat="server"/>
        </p>
       <span id="Messaggio" style="font: 8pt verdana;" runat="server"/>
       </form>
      </div>
     </body>
    </html>
    Richard B. Riddick : "Non avrete mica paura del buio?"

    Scusatemi ma sono mesi che non pago piu' la bolletta della luce....

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.