净应用。使用此应用程序,用户可以在一段时间内添加访客连接。为此,我有一个按钮,可以打开一个用户可以添加来宾的模式对话框。输入必须是名字、姓氏、公司和时间。我使用验证控件和 ValidationGroup。Validationcontrols 检查我是否忘记了输入,但如果我单击“添加”,则代码不会运行。我用一个简单的 div 尝试这个,但方法相同:
这是我的aspx代码:
<div id="add">
<div id="Div2" class="popupConfirmation" runat="server" style="width:350px; height:290px;">
<div class="bodycontrol">
<table>
<tr>
<td><asp:Label ID="Label3" runat="server" Text="Vorname"></asp:Label></td>
<td><asp:TextBox ID="TextBox1" runat="server" ValidationGroup="valid" ></asp:TextBox></td>
<td><asp:RequiredFieldValidator ID="RequiredFieldValidator1" ValidationGroup="valid" runat="server" ForeColor="red" ErrorMessage="*" ControlToValidate="TextBox1"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td><asp:Label ID="Label4" runat="server" Text="Nachname"></asp:Label></td>
<td><asp:TextBox ID="TextBox2" runat="server" ValidationGroup="valid"></asp:TextBox></td>
<td><asp:RequiredFieldValidator ID="RequiredFieldValidator2" ValidationGroup="valid" runat="server" ForeColor="red" ErrorMessage="*" ControlToValidate="TextBox2"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td><asp:Label ID="Label5" runat="server" Text="Firma"></asp:Label></td>
<td><asp:TextBox ID="TextBox3" runat="server" ValidationGroup="valid"></asp:TextBox></td>
<td><asp:RequiredFieldValidator ID="RequiredFieldValidator3" ValidationGroup="valid" runat="server" ForeColor="red" ErrorMessage="*" ControlToValidate="TextBox3"></asp:RequiredFieldValidator></td>
</tr>
</table>
<br />
<table>
<tr>
<td><asp:LinkButton ID="LinkButton1" runat="server" class="GuestButtons" Text="Hinzufügen" ValidationGroup="valid" onclick="btn_GuestListViewAddDialog_YES_Click" ></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton2" runat="server" class="GuestButtons" Text="Abbrechen" ValidationGroup="never"></asp:LinkButton></td>
</tr>
</table>
<br />
<table>
<tr>
<td><asp:Label ID="Label10" runat="server" Text="*Bitte alle Felder ausfüllen"></asp:Label></td>
</tr>
</table>
</div>
</div>
</div>
这是我的 C# 代码:
protected void btn_GuestListViewAddDialog_YES_Click(object sender, EventArgs e)
{
if (Page.IsValid) //Here i make a breakpoit but it doesn't use this code :(
{
...//here is my code
}
}
如果我单击链接按钮,这在我的脚本块中:
WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$lw_content$LinkButton1", "", true, "valid", "", false, true))