【问题标题】:Email not being generated or script not firing? [duplicate]电子邮件未生成或脚本未触发? [复制]
【发布时间】:2013-08-17 23:14:29
【问题描述】:

我有这个工作来生成一封电子邮件,但如果“ComplaintTextbox”包含超过 30 个字符,则电子邮件不会生成。??

<script type="text/javascript">
   function sendMail(CustomerTextbox, AddressTextBox, CityTextBox, StateDropDown, ZipTextBox, ModelTextbox, SerialTextbox, ReferenceTextbox, ComplaintTextBox, WarrentyTextBox) {
   var CustomerTextbox = document.getElementById(CustomerTextbox).value;
   var AddressTextBox = document.getElementById(AddressTextBox).value;
   var CityTextBox = document.getElementById(CityTextBox).value;
   var StateDropDown = document.getElementById(StateDropDown).value;
   var ZipTextBox = document.getElementById(ZipTextBox).value;
   var ModelTextbox = document.getElementById(ModelTextbox).value;
   var SerialTextbox = document.getElementById(SerialTextbox).value;
   var ReferenceTextbox = document.getElementById(ReferenceTextbox).value;
   var ComplaintTextBox = document.getElementById(ComplaintTextBox).value;
   var WarrentyTextBox = document.getElementById(WarrentyTextBox).value;

   var body = "Please issue a RMA for this case." + "\r\n";
   body += CustomerTextbox + "\r\n";
   body += AddressTextBox + "\r\n";
   body += CityTextBox + "\r\n";
   body += StateDropDown + "\r\n";
   body += ZipTextBox + "\r\n";
   body += ModelTextbox + "\r\n";
   body += SerialTextbox + "\r\n";
   body += ReferenceTextbox + "\r\n";
   body += ComplaintTextBox + "\r\n";
   body += WarrentyTextBox + "\r\n";

【问题讨论】:

  • 为什么不包含更多代码,例如带有 ID CustomerTextbox 的 asp:TextBox 和带有工作按钮的 sn-p 代码
  • 您是否使用 IE F12 工具验证没有向控制台报告任何内容?
  • 我认为这就是我在第二个代码行中的内容? "cmdEmail1"
  • 是的,我试过 F12 什么都没有
  • 好的,我得到了它的工作,但它只在字符串中包含“城市”时显示一个空白页 var body = "请为此案例发出 RMA。" + "\r\n" + "客户名称:" + CustomerTextbox + "\r\n" + "客户地址:" + AddressTextBox + "\r\n" + "City" 当我将 "City" 更改为 ""有用???

标签: javascript asp.net email


【解决方案1】:

您不应该对此造成完整的回发。您正在尝试使用 ASP.NET 提交按钮调用 javascript 函数,只需更改此按钮即可

<a href="javascript:void(0)" onclick="sendMail('<%=CustomerTextbox.ClientID %>')">
            <asp:Button ID="cmdEmail1" runat="server" Text="Generate Email RMA" 
                Width="158px" />
            </a> 

到这里:

  <a href="#" onclick="sendMail('<%=CustomerTextbox.ClientID %>')">
            Generate Email RMA
            </a> 

将开始让您的 Web 开发生活变得更加轻松和更具可扩展性。

【讨论】:

  • 当我尝试这个时,我在“/”应用程序中出现服务器错误。无法找到该资源。请求的网址:/0
  • 我只是想引导你朝着正确的方向前进,如果你能发布一个代码的工作示例,这样我就可以清楚地看到最终目标,这会很有帮助。我的回答最重要的是它向您展示了您可以在没有提交按钮的情况下将所有 javascript 回发到服务器。您在 javascript 中执行的操作仍然存在问题。
  • 好的,我得到了它的工作,但它只显示一个空白页,当字符串中包含“城市” var body = "请为此案例发出 RMA。" + "\r\n" + "客户姓名:" + CustomerTextbox + "\r\n" + "客户地址:" + AddressTextBox + "\r\n" + "城市"
  • 当我将“City”更改为“”时,它可以工作???
  • 您是否只是想提示用户他们需要为此案例签发 RMA?
猜你喜欢
  • 2012-09-12
  • 2021-03-31
  • 1970-01-01
  • 2023-03-15
  • 1970-01-01
  • 2014-04-23
  • 2014-05-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多