HTML,ASP - 联系表格不起作用

时间:2017-11-23 04:04:01

标签: html asp-classic

这是我希望在提交表单时连接到电子邮件的联系表单。我已经在网上研究过,但我似乎无法运行代码。

我有两个文件,其中一个是html代码,另一个是asp代码。

需要帮助。非常感谢您的指导。

<body>
<h3>Contact Form</h3>
  <form name="form1" method="post" action="process.asp">
    <label for="name">name</label>
    <input type="text" id="name"  name="name" placeholder="Your web id.."/>
    <br><br>
    <label for="deptID">Department ID</label>
    <input type="text" id="deptID" name="departmentID" placeholder="Your department ID..">
    <br><br>
    <label for="issue">Issue</label>
    <select id="issue" name="issue">
      <option value="">Non-Availability of Test Points</option>
      <option value="">Unable to Change Cycle Time Value</option>
      <option value="">Unable to Retrieve Report</option>
    </select>
    <br><br>
    <label for="subject">Additional Message</label>
    <textarea id="subject" name="subject" placeholder="Write something.." style="height:200px"></textarea>
      <br><br>
    <input type="submit" value="Submit">
  </form>

这是process.asp页面。

<%

formname = Request.Form("name")
formID = Request.Form("departmentID")
formquery = Request.Form("issue")
formsubject = Request.Form("subject")

Set Mail = Server.CreateObject("CDONTS.NewMail")

Mail.From = formname
Mail.FromName = formname


Mail.AddAddress "test@gmail.com"


Mail.Subject = "Form submitted from web site"


Bodytxt = "Details of Form submission :" & VbCrLf & VbCrLf
Bodytxt = Bodytxt & "Contact Name : " & formname & VbCrLf
Bodytxt = Bodytxt & "ID : " & formID & VbCrLf
Bodytxt = Bodytxt & "Query Entered : " & formquery & VbCrLf
Bodytxt = Bodytxt & "Subject Entered : " & formsubject


Mail.Body = Bodytxt


Mail.Username = "me@gmail.com"
Mail.Password = "password"


Mail.Host = "smtp.gmail.com"
Mail.Port = "587"
Mail.Send


Set Mail = Nothing

%>

1 个答案:

答案 0 :(得分:-1)

不确定您的代码片段是什么,但它们看起来非常不完整,您需要的堆不仅仅是将ASP页面连接到后端代码集。

使用C#和ASP.Net的标准设置如下。说我的页面被调用&#34; Default.aspx&#34;

这将是我的(正如你所说的是HTML,但实际上你的意思是你的ASP)

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
        </div>
    </form>
</body>
</html>

然后加入这将是C#ASP.Net

这看起来像这样:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}

上面所做的事情永远不会奏效,两个文件之间没有任何引用,你的第一段代码只是简单的HTML而不是ASP,没有任何东西可以定义你的C#环境。

我建议的是,获取Visual Studio 2015(免费),然后点击&#34; New&#34;并选择ASP网站。完成后,单击新项目并点击“#34;添加Web表单”#34;这将为您提供良好的开端,然后您就可以开始添加表单和代码了。

CAZ

相关问题