我正在尝试在我的项目中生成忘记密码的电子邮件。但是,当我点击发送密码按钮时,它会给我一个错误: - 未捕获的TypeError:无法读取属性' handler'未定义的。以下是我的代码。 我在我的视图中使用webflow创建的html类以及webflow。 JS脚本。我收到错误:-Uncaught TypeError:无法读取属性' handler'在webflow.js的下面代码中未定义。我希望当我点击我应该收到我的电子邮件ID上的邮件。我正在使用sendgrid发送电子邮件。
我的Js代码: -
function addListeners() {
listening = true;
// Handle form submission for Webflow forms
$doc.on('submit', namespace + ' form', function(evt) {
var data = $.data(this, namespace);
if (data.handler) {
data.evt = evt;
data.handler(data);
}
});
}
我的观看代码: -
@model InCubatize.Models.User
@{
ViewBag.Title = @Resources.LanguageResource.ForgotPasswordTitle;
}
<div class="w-container logo_container"><img class="login_logo" src="~/Images/images/Logo%20-%20Blue%20(V).png" width="100" alt="5488354fba4bc2be7fd98967_Logo%20-%20Blue%20(V).png">
</div>
<div class="w-container login_form_container">
<div class="w-form">
@using (Html.BeginForm()) {
<div class="card_main login_card_nest" id="email-form" name="email-form" data-name="Email Form" data-redirect="/login">
@Html.TextBoxFor(model => model.Email, new { @class="w-input login_textfield", id="Reg-Email", type="email", placeholder="Email", name="Reg-Email", data_name="Reg Email", required="required" })
<br />
@Html.ValidationMessageFor(model => model.Email)
<input class="w-button login_button" type="submit" value="Recover my password" data-wait="Please wait...">
@Html.ValidationSummary(true, "", new { @class= "ValidationSummaryMessages" })
<div class="login_textblock">New user?
<a href="~/#/user/register" class="tertiary_action_btn">Create account</a>
<span class="back_to_login">
<a href="~/#/user/login" class="tertiary_action_btn forgot_text">Back to login</a></span>
</div>
</div>}
<div class="w-form-done">
<p>Thank you! Your submission has been received!</p>
</div>
<div class="w-form-fail">
<p>Oops! Something went wrong while submitting the form :(</p>
</div>
</div>
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="~/Scripts/js/webflow.js"></script>
我的HTTP Post方法: -
[HttpPost]
public ActionResult ForgotPassword(string email)
{
try
{
User lUser = new User();
var userQuery = from u1 in db.Users
where u1.Email == email
select u1;
List<User> userList = userQuery.ToList();
if (userList.Count > 0)
{
foreach (User cu in userList)
{
if (cu.Status == (int)Enums.UserStatusType.Active)
{
string msg = HttpContext.GetGlobalResourceObject("LanguageResource", "ForgotYourPasswordEmailBody").ToString();
msg = msg.Replace("[FULLNAME]", cu.FullName);
string decryptedPassword = Encrypt.DecryptString(cu.Password);
decryptedPassword = decryptedPassword.Remove(0, cu.Id.ToString().Length);
msg = msg.Replace("[PASSWORD]", decryptedPassword);
string emailFrom = Helpers.CommonFunctions.GetApplicationSettingValue("SystemEmailId");
Emailer.SendEmail(cu.Email, HttpContext.GetGlobalResourceObject("LanguageResource", "ForgotYourPasswordEmailSubject").ToString(), msg, emailFrom);
ModelState.AddModelError("", HttpContext.GetGlobalResourceObject("LanguageResource", "ForgotYourPasswordEmailSuccessMessage").ToString());
return View();
}
else
{
ModelState.AddModelError("", HttpContext.GetGlobalResourceObject("LanguageResource", "InactiveUserMessage").ToString());
return View();
}
}
}
return View();
}
catch (Exception ex)
{
ModelState.AddModelError("", ex.ToString());
return View();
}
}