GVKun编程网logo

表单未在 ejs 模板中提交(表单未在 ejs 模板中提交怎么办)

8

对于想了解表单未在ejs模板中提交的读者,本文将提供新的信息,我们将详细介绍表单未在ejs模板中提交怎么办,并且为您提供关于.net–在更新面板中提交表单后运行javascript?、Angular6

对于想了解表单未在 ejs 模板中提交的读者,本文将提供新的信息,我们将详细介绍表单未在 ejs 模板中提交怎么办,并且为您提供关于.net – 在更新面板中提交表单后运行javascript?、Angular 6:表单提交取消,因为表单未连接、Angular 模板表单:如果表单未更改,则禁用提交、ASP.Net 2.0:提交后表单未重定向的有价值信息。

本文目录一览:

表单未在 ejs 模板中提交(表单未在 ejs 模板中提交怎么办)

表单未在 ejs 模板中提交(表单未在 ejs 模板中提交怎么办)

如何解决表单未在 ejs 模板中提交?

这是用ejs编写的形式。

<formaction="/admin/<% if (editing) { %>edit-product<% } else { %>add-product<% } %>" method="POST" enctype="multipart/form-data">
            <div>
                <label for="title">Title</label>
                <inputhttps://www.jb51.cc/tag/ara/" target="_blank">aram === ''title'') ? ''invalid'' : '''' %>"
                    type="text" 
                    name="title" 
                    id="title" 
                    value="<% if (editing || hasError) { %><%= product.title %><% } %>">
            </div>
            <div>
                <label for="image">Image</label>
                <input 
                    type="file" 
                    name="image" 
                    id="image" >
            </div>
            <div>
                <label for="price">Price</label>
                <!-- express-validator returns array of errors  -->
                <inputhttps://www.jb51.cc/tag/ara/" target="_blank">aram === ''price'') ? ''invalid'' : '''' %>"
                    type="number" 
                    name="price" 
                    id="price" 
                    step="0.01" 
                    value="<% if (editing || hasError) { %><%= product.price %><% } %>">
            </div>
            <div>
                <label for="description">Description</label>
                <textareahttps://www.jb51.cc/tag/ara/" target="_blank">aram === ''description'') ? ''invalid'' : '''' %>"
                    name="description" 
                    id="description" 
                    rows="5"><% if (editing || hasError) { %><%= product.description %><% } %></textarea>
            </div>
            <% if (editing) { %>
                <input type="hidden" value="<%= product._id %>" name="productId">
            <% } %>

            <input type="hidden" name="_csrf" value="<%= csrftoken %>">
            <buttontype="submit"><% if (editing) { %>Update Product<% } else { %>Add Product<% } %></button>
        </form>

由于我正在上传图片,enctype="multipart/form-data"。当我点击按钮时,没有任何反应。没有发布请求,我检查了网络请求,什么都没有

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

.net – 在更新面板中提交表单后运行javascript?

.net – 在更新面板中提交表单后运行javascript?

这真让我抓狂!我已经阅读了至少5个与我的问题密切相关的问题,并且可能只有5个左右的网页来自谷歌搜索.我只是不明白.

我试图在用户填写表格“注册提交”然后重定向到另一个页面后出现jqueryui对话框,但我不能为我的生活让任何javascript工作,甚至没有一个警报.

这是我的更新面板:

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="upForm" runat="server" 
    UpdateMode="Conditional" ChildrenAsTriggers="False">
    <ContentTemplate>
               'Rest of form'
         <asp:Button ID="btnSubmit" runat="server" Text="Submit" /> 
              <p>Did register Pass? <%= registrationComplete %></p>
    </ContentTemplate>
</asp:UpdatePanel>

我想要执行的Jquery :(现在它位于标记的头部,autoOpen设置为false)

<script type="text/javascript"> 
function pageLoad() {

    $('#registerComplete').dialog({
        autoOpen: true,
        width: 270,
        resizable: false,
        modal: true,
        draggable: false,
        buttons: {
          "Ok": function() {
          window.location.href = "someUrl";
        }
        }
    });

}
     </script>

最后我的代码背后:(注释掉我试过的所有东西)

Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click     
      'Dim sbScript As New StringBuilder()'
           registrationComplete = True
            registrationUpdatePanel.Update()

            'sbScript.Append("<script language='JavaScript' type='text/javascript'>" + ControlChars.Lf)'
            'sbScript.Append("<!--" + ControlChars.Lf)'
            'sbScript.Append("window.location.reload()" + ControlChars.Lf)'
            'sbScript.Append("// -->" + ControlChars.Lf)'
            'sbScript.Append("</")'
            'sbScript.Append("script>" + ControlChars.Lf)'

            'ScriptManager.RegisterClientScriptBlock(Me.Page, Me.GetType(), "AutopostBack", sbScript.ToString(), False)'
            'ClientScript.RegisterStartupScript("AutopostBackScript", sbScript.ToString())'
                            'Response.Write("<script type='text/javascript'>alert('Test')</script>")'
            'Response.Write("<script>windows.location.reload()</script>")'
End Sub

我试过了:

>将变量从服务器传递到
客户通过内联<%=%>在里面
头标记的javascript块.
>将相同的代码放在脚本中
updatePanel中的标记.
>试图使用
RegisterClientScriptBlock和
的RegisterStartupScript
>只需使用.做一个Response.Write
脚本标签写在里面.
>尝试了推杆的各种组合
整个jquery.dialog代码
registerstartup脚本,或者只是
试图改变autoOpen
财产,或只是打电话给“开放”
它.

我甚至无法得到一个简单的警报来处理任何这些,所以我做错了但我只是不知道它是什么.

这就是我所知道的:

> Jquery甚至可以正确绑定
关于异步回发,因为div
作为对话框的容器是
总是看不见的,我看到了一个相似的
在这里发帖说明是造成的
一个问题,这不是这里的情况.
>使用page_load而不是
document.ready自那以后
在异步和正常运行
回发,所以这不是问题.
>更新面板正在更新
正确,因为< p>注册了
通过? <%= registrationComplete
%GT;&LT / p为H.在我之后更新为true
提交表格.

那我怎么能做这个呢?我想要的只是 – >点击更新面板内的提交按钮 – >运行服务器端代码以验证表单并插入到db – >如果一切都成功了,请弹出jquery(模态)对话框,说它有效.

解决方法:

要从Codebehind注册,here’s the format:

ClientScript.RegisterStartupScript(GetType(), "AutopostBackScript", 
                                   "alert('hi');", True);

最后的真实告诉它将你的代码包装在< script>中标签,如果你想自己做标签,请将其关闭.

Angular 6:表单提交取消,因为表单未连接

Angular 6:表单提交取消,因为表单未连接

如何解决Angular 6:表单提交取消,因为表单未连接

我正在尝试构建表单,但收到“表单提交已取消,因为表单未连接”警告。

删除了一些输入以使其更具可读性。

HTML:

<form name="newProduct" id="newProduct" (ngSubmit)="saveNewProduct()" [formGroup]="newProduct">
  <label for="productId">Id</label><br />
  <input name="productId" id="productId" type="number" formControlName="productId" placeholder="productId" autocomplete="off" />
   <m-spinner-button [options]="spinner" type="submit" (click)="modal.close()">ADD PRODUCT</m-spinner-button>
</form>

component.ts

  newProduct = new FormGroup({
    productId: new FormControl("")
  });

  saveNewProduct(){
    console.log(this.newProduct.value)
  }

这里有什么问题,应该是连通的?

解决方法

如果您的表单处于模态,那么关闭模态的点击处理程序似乎在提交之前销毁/卸载表单。更新按钮以移除点击处理程序。如果您想在提交后关闭模态,您可以将模态 close 移动到事件处理程序的主体中:

模板:

<form name="newProduct" id="newProduct" (ngSubmit)="saveNewProduct()" [formGroup]="newProduct">
  <label for="productId">Id</label><br />
  <input name="productId" id="productId" type="number" formControlName="productId" placeholder="productId" autocomplete="off" />
   <m-spinner-button [options]="spinner" type="submit">ADD PRODUCT</m-spinner-button>
</form>

控制器:

saveNewProduct() {
  // ... your existing code
  this.modal.close(); // close the modal when everything else is done
}

希望有帮助!

Angular 模板表单:如果表单未更改,则禁用提交

Angular 模板表单:如果表单未更改,则禁用提交

如何解决Angular 模板表单:如果表单未更改,则禁用提交?

这是我的代码

          <form (ngSubmit)="onSubmit()" #f="ngForm">
            <input placeholder="Order ID" type="text" id="orderId"name="orderId" [(ngModel)]="orderId" required>
            <buttontype="submit" [disabled]="!(f.valid && f.dirty)">Search</button>
          </form>

如果输入没有改变,我希望按钮被禁用,但它没有改变。有谁知道为什么?

解决方法

脏/!原始表示用户进行了修改

在您的情况下,如果您输入某些内容然后将其恢复为原始值,表单仍将保持

要检查是否有任何差异,您需要实现自己的方法。

Demo

,

正如罗伯特所说,你可以“玩”质朴。例如

<form [formGroup]="form">
  <input formControlName="control">
  <button (click)="submit(form)" 
          [disabled]="!form.valid || form.pristine">submit</button>
</form>

  submit(form)
  {
    if (form.valid) //if valid mark as "pristine"
    {
      form.markAsPristine();
      console.log("submited") //do something
    }
    else
      form.markAllAsTouched(); //mark all the controls as touched
                               //to show the errors
  }

stackblitz

ASP.Net 2.0:提交后表单未重定向

ASP.Net 2.0:提交后表单未重定向

如何解决ASP.Net 2.0:提交后表单未重定向?

我需要解决一个复杂的ASP.Net 2.0情况。自2010年左右以来,我还没有写过任何代码,但我可能是公司中唯一有志于实现这一目标的人。

我们有一个将要替换的旧版Windows 2003 Web服务器。但是我们公司的网站,两个ClickOnce部署和几个内部实用程序正在上面运行,并且服务不会中断。该网站是用ASP.Net 2.0(背后是vb.net代码)编写的。因此,我们需要能够将站点迁移到替代服务器。

我们设置了Windows 2012服务器,计划将其用于托管旧网站,直到我们开发新网站为止,届时我们将继续升级到最新的Windows Server平台。

在此过程中,主要的浏览器开始拒绝使用少于TLS 1.2协议,而Windows Server 2003则不支持该协议。当客户端尝试提交我们正在运行的可填写的联系表时,问题就变得很明显。由于TLS问题,表单提交被拒绝。

因此,我们使用了通配符SSL证书并将其绑定到新的2012服务器。创建了一个子域,称为contact.ourdomain.com。我们有一个在新服务器上运行的网站副本。联系人表单的所有链接均已更新,以指向“ contact.ourdomain.com/contact.aspx”,该地址托管在新服务器上。因此,现在可以避免TLS问题。

但是,表格有问题。在Visual Studio中执行时,它可以正常工作。但是,一旦将其发布到新服务器上,该表单就不会显示确认对话框或重定向到我们的主页。这意味着一旦填写了表单并单击“提交”,它将发送电子邮件,然后坐在那里。它不显示对话框或重定向。因此,客户不仅最终提交了5次这样的表单,他们甚至不知道表单是否有效。如何强制此代码运行到完成?

任何解决此问题的方法都可以。 Javascript,随便。这是一个临时解决方法,我只需要它工作到今年年底即可;到那时,到新服务器的迁移将完成。

''''''''导入System.Net.Mail

部分公开课联系方式 继承System.Web.UI.Page 公共StrPubMessage作为字符串 公开的BlnReady为布尔值

Protected Sub Page_Load(ByVal sender As Object,ByVal e As System.EventArgs) Handles Me.Load
    If Not Page.IsPostBack Then
        lblMsgBox.Visible = False
    Else

    End If
End Sub

Public Sub btnSubmit_Click(ByVal sender As Object,ByVal e As EventArgs) Handles btnSubmit.Click

    Try
        '' validate the Captcha to check we''re not dealing with a bot

        Dim isHuman As Boolean = frmCaptcha.Validate(txtCaptchaCode.Text)
        txtCaptchaCode.Text = nothing

        If Not isHuman Then
            MsgBox("Please enter Captcha code.",MsgBoxStyle.OkOnly,"LDC Website")

        Else

            Dim emailclient As New SmtpClient("smtp.office365.com")
            emailclient.EnableSsl = True
            emailclient.Credentials = New System.Net.NetworkCredential("notifications@Ourdomain.com","Our_Domain2020")


            Dim toEmailAddress As New MailAddress("email@Ourdomain.com")
            Dim fromEmailAddress As New MailAddress("notifications@Ourdomain.com")
            Dim emailMessage As New MailMessage(fromEmailAddress,toEmailAddress)
            Dim messageString As String

            emailMessage.IsBodyHtml = False
            emailMessage.BodyEncoding = System.Text.Encoding.UTF32

            emailMessage.Subject = "Message from website"

            messageString = "The following is an email inquiry from Ourdomain.com:" & vbCrLf + Chr(13) + Chr(10)
            messageString = messageString + "Name:                = " + txtName.Text & vbCrLf
            messageString = messageString + "Company Name:        = " & txtCoName.Text & vbCrLf
            messageString = messageString + "EMAIL:               = " & txtEmail.Text & vbCrLf
            messageString = messageString + "General Comment" & vbCrLf & vbCrLf & txtComment.Text & vbCrLf
            messageString = messageString + "End of inquiry." & vbCrLf & vbCrLf

            emailMessage.Body = messageString

            emailclient.Send(emailMessage)

            MsgBox("Your message was successfully transmitted to our team." _
                   & vbCrLf & "You will be contacted within 1 business day." _
                   & vbCrLf & "Thank you for your inquiry.","Our Website")
            Response.Redirect("https://www.Ourdomain.com",False)

        End If

    Catch ex As Exception

        MsgBox("Your message Could not be sent due to an unkNown error. Please try again.",MsgBoxStyle.OkOnly)
        Response.Redirect("https://www.Ourdomain.com",False)

    End Try

End Sub

结束课程''''''

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

我们今天的关于表单未在 ejs 模板中提交表单未在 ejs 模板中提交怎么办的分享就到这里,谢谢您的阅读,如果想了解更多关于.net – 在更新面板中提交表单后运行javascript?、Angular 6:表单提交取消,因为表单未连接、Angular 模板表单:如果表单未更改,则禁用提交、ASP.Net 2.0:提交后表单未重定向的相关信息,可以在本站进行搜索。

本文标签: