protected void Button1_Click(object sender, EventArgs e) { int v1, v2, result; Label_Error.Text = ""; try { v1 = Int32.Parse(TextBox1.Text); v2 = Int32.Parse(TextBox2.Text); } catch (Exception ex) { if (ex.Message[0] == 'A') { RangeValidator2.Validate(); } else { RequiredFieldValidator2.Validate(); } return; } result = v1 / v2; TextBox3.Text = result.ToString(); Label_Error.Text = "Divide error"; }
protected void Selection_Change(Object sender, EventArgs e) { SqlCommand cmd = connectionString.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "select size, places from halls where hall_id='" + hall.SelectedValue.ToString() + "'"; cmd.ExecuteNonQuery(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); foreach (DataRow dr in dt.Rows) { max_places.Text = "Maksymalna ilość miejsc: " + dr["places"].ToString(); size.Text = "Rozmiar sali: " + dr["size"].ToString(); RangeValidator2.MaximumValue = (dr["places"]).ToString(); RangeValidator2.Type = ValidationDataType.Integer; RangeValidator2.Validate(); } }
protected void Button1_Click(object sender, EventArgs e) { RangeValidator1.Validate(); if (RangeValidator1.IsValid) { Label1.Text = "Result : Valid!"; } else { Label1.Text = "Result : Not Valid!"; } RangeValidator2.Validate(); if (RangeValidator2.IsValid) { Label2.Text = "Result : Valid!"; } else { Label2.Text = "Result : Not Valid!"; } RangeValidator3.Validate(); if (RangeValidator3.IsValid) { Label3.Text = "Result : Valid!"; } else { Label3.Text = "Result : Not Valid!"; } if (Page.IsValid) { Label4.Text = "Result : Valid!"; } else { Label4.Text = "Result : Not Valid!"; } }