Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 如何防止在代码隐藏中单击按钮时出现响应?_Asp.net_Vb.net_Webforms_Postback_Buttonclick - Fatal编程技术网

Asp.net 如何防止在代码隐藏中单击按钮时出现响应?

Asp.net 如何防止在代码隐藏中单击按钮时出现响应?,asp.net,vb.net,webforms,postback,buttonclick,Asp.net,Vb.net,Webforms,Postback,Buttonclick,我有一个带有表单的aspx页面,该表单包含一个asp按钮,该按钮在页面上的代码后面有一个单击处理程序。我希望能够单击表单上的按钮,调用click处理程序,执行代码隐藏中的逻辑,但在click处理程序事件完成后不返回响应/回发 表格编号: 你必须使用Ajax。在本例中,最简单的方法是使用更新面板 您必须将ScriptManager添加到页面: <asp:ScriptManager ID="ScriptManager1" runat="server" /> 更新面板类: 你能用我的

我有一个带有表单的aspx页面,该表单包含一个asp按钮,该按钮在页面上的代码后面有一个单击处理程序。我希望能够单击表单上的按钮,调用click处理程序,执行代码隐藏中的逻辑,但在click处理程序事件完成后不返回响应/回发

表格编号:


你必须使用Ajax。在本例中,最简单的方法是使用更新面板

您必须将ScriptManager添加到页面:

<asp:ScriptManager ID="ScriptManager1" runat="server" />

更新面板类

你能用我的代码给我举个例子吗?我不熟悉ScriptManager或UpdatePanel。只需将ScriptManager控件添加到页面中,并将html表的所有代码插入更新面板的区域中。ScriptManager控件和更新面板是否都位于表单的内部?是的,所有ASP.Net服务器控件都必须放置在标记中。谢谢,这正是我所需要的。实际上,我正在将此表单加载到jQuery UI对话框中,并从jQuery调用按钮click,然后在表单提交后重新加载父页面。
Partial Public Class ItemEdit
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) 
Handles Me.Load
    If (Not Page.IsPostBack) Then
        If Request.QueryString("itemId") IsNot Nothing Then
            Dim itemId As String = Request.QueryString("itemId")
            Dim command As New OleDbCommand("SELECT * FROM items 
WHERE id = " & itemId, New OleDbConnection(ConnectionString))
            Try
                command.Connection.Open()
                Dim reader As OleDbDataReader = command.ExecuteReader()
                If reader.Read() Then
                    lblItem.Text = reader("item")
                    cbxMB.Checked = reader("mb")
                    cbxPP.Checked = reader("pp")
                    cbxB.Checked = reader("b")
                    cbxT.Checked = reader("t")
                    lblItemId.Text = reader("id")
                End If
                reader.Close()
            Finally
                command.Connection.Close()
            End Try
        End If
    End If
End Sub

Protected Sub btnSave_Click(ByVal sender As System.Object, ByVal e As  
System.EventArgs) Handles btnSave.Click
    Dim command As New OleDbCommand("UPDATE items SET b=" & 
Math.Abs(CInt(cbxB.Checked)) & ",t=" & Math.Abs(CInt(cbxT.Checked)) & 
",mb=" & Math.Abs(CInt(cbxMB.Checked)) & ",pp=" & 
Math.Abs(CInt(cbxPP.Checked)) & " WHERE id=" & lblItemId.Text, New 
OleDbConnection(ConnectionString))
    Try
        command.Connection.Open()
        command.ExecuteNonQuery()
    Finally
        command.Connection.Close()
    End Try
End Sub
End Class
<asp:ScriptManager ID="ScriptManager1" runat="server" />
 <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                    <table>
                         ... table content from example
                    </table>
            </ContentTemplate>
  </asp:UpdatePanel>