我无法将记录添加到数据库asp.net

时间:2017-01-03 23:31:33

标签: javascript c# html asp.net

我有一个问题,我想在数据库中添加一些记录,但是当我点击提交按钮时,什么也没做。

提交按钮的一些功能:

protected void rezerwujButton_Click(object sender, EventArgs e)
    {
        rezerwacje nowaRezerwacja = new rezerwacje();

        nowaRezerwacja.imie_klienta = imieTextBox.Text;
        nowaRezerwacja.nazwisko_klienta = nazwiskoTextBox.Text;
        nowaRezerwacja.email_klienta = emailTextBox.Text;
        nowaRezerwacja.nrtel_klienta = telefonKomorkowyTextBox.Text;

        bazaDC.rezerwacjes.InsertOnSubmit(nowaRezerwacja);
        bazaDC.SubmitChanges();
    }

html中的一些表单:

<div id="dialog" title="Rezerwacja">
      <asp:Panel ID="panel3" runat="server">
        <asp:TextBox ID="imieTextBox" runat="server" placeholder="Imię"></asp:TextBox>
        <asp:TextBox ID="nazwiskoTextBox" runat="server" placeholder="Nazwisko"></asp:TextBox>
        <asp:TextBox ID="emailTextBox" runat="server" TextMode="Email" placeholder="Email"></asp:TextBox>
        <asp:TextBox ID="telefonKomorkowyTextBox" runat="server" TextMode="Phone" placeholder="Telefon kom."></asp:TextBox>
        <div id="plansza"></div>
        <asp:Button ID="rezerwujButton" runat="server" Text="Zarezerwuj" OnClick="rezerwujButton_Click" />

        </asp:Panel>

在此表单中有一个弹出窗口。 我无法理解,因为在我拥有多种形式的代码之前,一切都很好,但现在很遗憾没有......那些代码有什么问题? 我将添加一些jquery代码,打开窗口窗口:

$(document).ready( function() {
  $( "#dialog" ).dialog({
      autoOpen: false,
      show: {
          effect: "puff",
          duration: 1000
      },
      hide: {
          effect: "explode",
          duration: 1000
      }
  });

  $( ".opener" ).on( "click", function() {
      $( "#dialog" ).dialog( "open" );
  });
});

1 个答案:

答案 0 :(得分:0)

尝试使用onclient点击现有按钮。

<asp:Button ID="rezerwujButton" runat="server" Text="Zarezerwuj" OnClientClick="clientClick();" />

然后使用您已构建的rezerwujButton_Click功能创建隐藏按钮。

<asp:Button id="hidButton" runat="server" style="visibility: hidden; display: none;" onclick="rezerwujButton_Click" />

创建以下javascript函数以触发隐藏按钮上的回发。

function clientClick(){
    __doPostBack('<%#hidButton.UniqueId %>');
}
相关问题