fix: add clear button to "Practice.ValidWeb"
This commit is contained in:
parent
0c76bf44c3
commit
2356218e51
22
Practice/ValidWeb/Forma1-clear.aspx.cs
Normal file
22
Practice/ValidWeb/Forma1-clear.aspx.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace ValidWeb
|
||||
{
|
||||
public partial class Forma1 : System.Web.UI.Page
|
||||
{
|
||||
|
||||
protected void Button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
Session.Clear();
|
||||
for (int i = Table1.Rows.Count-1; i > 0; i--)
|
||||
{
|
||||
Table1.Rows.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -41,6 +41,9 @@
|
||||
<br />
|
||||
<asp:Button ID="Button1" runat="server" Text="Registruotis" OnClick="Button1_Click" />
|
||||
<br />
|
||||
<br />
|
||||
<asp:Button ID="Button2" runat="server" Text="Išvalyti" OnClick="Button2_Click" />
|
||||
<br />
|
||||
<br />
|
||||
<asp:Table ID="Table1" runat="server" BackColor="#FFFFCC" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" GridLines="Both">
|
||||
</asp:Table>
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
@ -45,10 +46,15 @@ namespace ValidWeb
|
||||
protected void Button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
string name = TextBox1.Text;
|
||||
if (Regex.IsMatch(name, @"[^a-zA-Z]")) { return; }
|
||||
|
||||
string surname = TextBox2.Text;
|
||||
if (Regex.IsMatch(surname, @"[^a-zA-Z]")) { return; }
|
||||
|
||||
string school = TextBox3.Text;
|
||||
string age = DropDownList1.Text;
|
||||
string language = CheckBoxList1.sele;
|
||||
string language = CheckBoxList1.SelectedValue;
|
||||
|
||||
string user = String.Join("|", name, surname, school, age, language);
|
||||
if (Session["users"] == null) {
|
||||
Session["users"] = user;
|
||||
@ -70,5 +76,7 @@ namespace ValidWeb
|
||||
|
||||
Table1.Rows.Add(row);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
9
Practice/ValidWeb/Forma1.aspx.designer.cs
generated
9
Practice/ValidWeb/Forma1.aspx.designer.cs
generated
@ -185,6 +185,15 @@ namespace ValidWeb
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Button Button1;
|
||||
|
||||
/// <summary>
|
||||
/// Button2 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Button Button2;
|
||||
|
||||
/// <summary>
|
||||
/// Table1 control.
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user