//確認資料後允許報名 public bool CheckRegistrationData() { string errMes = ""; int mainCount = 1; //隊名要填 if (input_TeamName.Value == "") { errMes += $"<p>{mainCount}. 請填寫隊名</p>"; mainCount++; } int count = (Request.Form.AllKeys.Where(key => key.Contains("input_Name")).ToList()).Count; bool hasLeader = false; for (int i = 1; i <= count; i++) { HtmlInputRadioButton btn = Master.FindControl("MainContent").FindControl("radioBtn_" + i) as HtmlInputRadioButton; HtmlInputText nameControl = Master.FindControl("MainContent").FindControl("input_Name" + i) as HtmlInputText; //是否為隊長 if (btn.Checked) { hasLeader = true; } //判斷隊伍資訊 string memberError = $"<p>{mainCount}. 請確認隊員{i}資訊:</p>"; //判斷名字有沒有寫 if (nameControl.Value == "") { memberError += $"<p style=\"margin-left: 10px; margin-top: 0px;\">.姓名不可留空!</p>"; } if (memberError != $"<p>{mainCount}. 請確認隊員{i}資訊:</p>") { errMes += memberError; mainCount++; } } //確認有沒有隊長 if (!hasLeader) { errMes += $"<p>{mainCount}. 請選擇一位隊長!</p>"; mainCount++; } if (errMes == "") { return(true); } else { Modal_Body.InnerHtml = errMes; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "closepup", "$('#Modal_ErrMsg').modal('show');", true); return(false); } }
public static Hashtable GetWebControls(Control page) { Hashtable ht = new Hashtable(); int size = HttpContext.Current.Request.Params.Count; for (int i = 0; i < size; i++) { string id = HttpContext.Current.Request.Params.GetKey(i); Control control = page.FindControl(id); if (control != null) { control = page.FindControl(id); if (control is HtmlInputText) { HtmlInputText txt = (HtmlInputText)control; ht[txt.ID] = txt.Value.Trim(); } if (control is TextBox) { TextBox txt2 = (TextBox)control; ht[txt2.ID] = txt2.Text.Trim(); } if (control is HtmlSelect) { HtmlSelect txt3 = (HtmlSelect)control; ht[txt3.ID] = txt3.Value.Trim(); } if (control is HtmlInputHidden) { HtmlInputHidden txt4 = (HtmlInputHidden)control; ht[txt4.ID] = txt4.Value.Trim(); } if (control is HtmlInputPassword) { HtmlInputPassword txt5 = (HtmlInputPassword)control; ht[txt5.ID] = txt5.Value.Trim(); } if (control is HtmlInputCheckBox) { HtmlInputCheckBox chk = (HtmlInputCheckBox)control; ht[chk.ID] = (chk.Checked ? 1 : 0); } if (control is HtmlTextArea) { HtmlTextArea area = (HtmlTextArea)control; ht[area.ID] = area.Value.Trim(); } if (control is HtmlInputRadioButton) { HtmlInputRadioButton radio = (HtmlInputRadioButton)control; if (radio.Checked) { ht[radio.Name] = radio.Value.Trim(); } } } } return(ht); }
/// <summary> /// Selects the radio button option. /// </summary> /// <param name="optionId">The option id.</param> public void SelectRadioButtonOption(TagsRadioButtonIds optionId) { ActiveBrowser.WaitForElement(new HtmlFindExpression("tagname=input", "id=" + optionId)); HtmlInputRadioButton radioButton = ActiveBrowser.Find.ByExpression <HtmlInputRadioButton>("tagname=input", "id=" + optionId) .AssertIsPresent("radio button"); radioButton.Click(); }
/// <summary> /// Verifies the checked radio button option. /// </summary> /// <param name="optionId">The option id.</param> public void VerifyCheckedRadioButtonOption(TagsRadioButtonIds optionId) { ActiveBrowser.WaitForElement("tagname=input", "id=" + optionId); HtmlInputRadioButton radioButton = ActiveBrowser.Find.ByExpression <HtmlInputRadioButton>("tagname=input", "id=" + optionId) .AssertIsPresent("radio button"); Assert.IsTrue(radioButton.Checked); }
/// <summary> /// Select email address /// </summary> public void SelectEmailAddress() { HtmlInputRadioButton emailAddress = this.EM.EmailCampaigns.UnsubscribeEditScreen.EmailAddress.AssertIsPresent("Email address"); emailAddress.Click(); ActiveBrowser.RefreshDomTree(); ActiveBrowser.WaitUntilReady(); }
private void rad_DataBinding(object sender, EventArgs e) { HtmlInputRadioButton rad = (HtmlInputRadioButton)sender; rad.Value = strText; rad.Checked = blChecked; rad.Visible = Visibility; }
/// <summary> /// Select external url option /// </summary> public void SelectExternalUrlOption() { HtmlInputRadioButton selectExternalUrl = EM.Card.CardEditScreen.ExternalURLRadioButton.AssertIsPresent("External url"); selectExternalUrl.ScrollToVisible(); selectExternalUrl.Focus(); selectExternalUrl.MouseClick(); }
public void ScrollToVisible() { manager.ActiveBrowser.NavigateTo( "http://automatetheplanet.com/healthy-diet-menu-generator/"); HtmlInputRadioButton coffeeRadioButton = manager.ActiveBrowser.Find.ByExpression <HtmlInputRadioButton>("value=^1 x Trenta"); coffeeRadioButton.ScrollToVisible(ScrollToVisibleType.ElementTopAtWindowTop); }
/// <summary> /// Switch to Both mode only /// </summary> public void SwitchToBothMode() { HtmlInputRadioButton bothMode = EM.Identity.ProfileEditScreen.BothReadModeCanBeEditedMode .AssertIsPresent("Both mode only button"); bothMode.Click(); ActiveBrowser.WaitUntilReady(); ActiveBrowser.WaitForAsyncJQueryRequests(); }
/// <summary> /// Switch to Read mode only /// </summary> public void SwitchToReadMode() { HtmlInputRadioButton readMode = EM.Identity.ProfileEditScreen.ReadModeOnly .AssertIsPresent("Read mode only button"); readMode.Click(); ActiveBrowser.WaitUntilReady(); ActiveBrowser.WaitForAsyncJQueryRequests(); }
/// <summary> /// Switches to link file option. /// </summary> public void SwitchToLinkFileOption() { HtmlInputRadioButton linkToCssFile = EM.ScriptsAndStyles.ScriptsAndStylesEditScreen.LinkToFile .AssertIsPresent("Link to css file button"); linkToCssFile.Click(); ActiveBrowser.WaitUntilReady(); ActiveBrowser.WaitForAsyncJQueryRequests(); }
/// <summary> /// /// </summary> protected virtual void SetIndexValue(HtmlInputRadioButton radioSelector) { DataGridItem row = radioSelector.NamingContainer as DataGridItem; if (row != null) { radioSelector.Value = row.ItemIndex.ToString(); } }
public void AddTeamCount(int count) { HtmlGenericControl formGroup = CreateDiv("form-group row", "font-size: 18px;"); formGroup.ID = "form_Team" + count; formGroup.Attributes.Add("name", "form_Team" + count); HtmlGenericControl colNo = CreateDiv("col-2", "margin-right: 0px;"); colNo.InnerText = "隊員" + count + ":"; HtmlGenericControl colName = CreateDiv("col-2", "margin-left: 0px;"); HtmlInputText inputName = new HtmlInputText("text"); inputName.Attributes.Add("class", "form-control"); inputName.Attributes.Add("style", "font-size: 8px; width: 150px;"); inputName.Attributes.Add("runat", "server"); inputName.ID = "input_Name" + count; HtmlGenericControl colId = CreateDiv("col-2", "margin-left: 25px;"); HtmlInputText inputId = new HtmlInputText("text"); inputId.Attributes.Add("class", "form-control"); inputId.Attributes.Add("style", "font-size: 8px; width: 150px;"); inputId.Attributes.Add("placeholder", "A123456789"); inputId.Attributes.Add("maxlength", "10"); inputId.Attributes.Add("runat", "server"); inputId.ID = "input_Id" + count; HtmlGenericControl colBirthday = CreateDiv("col-2", "margin-left: 25px;"); HtmlInputText inputBirthday = new HtmlInputText("text"); inputBirthday.Attributes.Add("class", "form-control"); inputBirthday.Attributes.Add("style", "font-size: 8px; width: 150px;"); inputBirthday.Attributes.Add("placeholder", "yyyy-mm-dd"); inputBirthday.Attributes.Add("maxlength", "10"); inputBirthday.Attributes.Add("runat", "server"); inputBirthday.ID = "input_Birthday" + count; HtmlGenericControl colLeader = CreateDiv("col-2", "margin-left: 73px; margin-top: 7px;"); HtmlInputRadioButton btn = new HtmlInputRadioButton(); btn.Attributes.Add("class", "form-check"); btn.Attributes.Add("runat", "server"); btn.ID = "radioBtn_" + count; HtmlGenericControl col_Final = CreateDiv("col-2", "margin-right: 20px;"); colName.Controls.Add(inputName); colId.Controls.Add(inputId); colBirthday.Controls.Add(inputBirthday); colLeader.Controls.Add(btn); formGroup.Controls.Add(colNo); formGroup.Controls.Add(colName); formGroup.Controls.Add(colId); formGroup.Controls.Add(colBirthday); formGroup.Controls.Add(colLeader); formGroup.Controls.Add(col_Final); fieldSpace.Controls.Add(formGroup); }
protected void replayer_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { HtmlInputRadioButton chknchecklayer = (HtmlInputRadioButton)e.Item.FindControl("radionLayer"); chknchecklayer.Attributes.Add("onclick", "seteventcolor(" + DataBinder.Eval(e.Item.DataItem, "nid").ToString() + ",this);"); } }
/// <summary> /// Verifies the checked radio button option. /// </summary> /// <param name="optionId">The option id.</param> public void VerifyCheckedRadioButtonOption(WidgetDesignerRadioButtonIds optionId) { HtmlFindExpression expression = new HtmlFindExpression("tagname=input", "id=" + optionId); ActiveBrowser.WaitForElement(expression, 60000, false); HtmlInputRadioButton radioButton = ActiveBrowser.Find.ByExpression <HtmlInputRadioButton>("tagname=input", "id=" + optionId) .AssertIsPresent("radio button"); Assert.IsTrue(radioButton.Checked); }
protected void ASPxGridView1_HtmlRowCreated(object sender, ASPxGridViewTableRowEventArgs e) { if (e.RowType == GridViewRowType.Data) { GridViewDataColumn col = ((ASPxGridView)sender).Columns["Description"] as GridViewDataColumn; HtmlInputRadioButton btn = ((ASPxGridView)sender).FindRowCellTemplateControl(e.VisibleIndex, col, "group1") as HtmlInputRadioButton; btn.Checked = ((ASPxGridView)sender).Selection.IsRowSelected(e.VisibleIndex); btn.Attributes.Add("onclick", "grid.PerformCallback(" + e.VisibleIndex.ToString() + "+';'+this.checked)"); } }
private void ClearSelectedValue() { foreach (GridViewRow row in formGridView.Rows) { HtmlInputRadioButton r = (HtmlInputRadioButton)row.Controls[0].Controls[0]; if (r.Checked) { r.Checked = false; } } }
public void NullProperties() { HtmlInputRadioButton rb = new HtmlInputRadioButton(); rb.Name = null; Assert.AreEqual(String.Empty, rb.Name, "Name"); rb.Value = null; Assert.IsNull(rb.Value, "Value"); Assert.AreEqual(defaultAttributesCount, rb.Attributes.Count, "Attributes.Count"); }
private string GetSelectedValue() { foreach (GridViewRow row in formGridView.Rows) { HtmlInputRadioButton r = (HtmlInputRadioButton)row.Controls[0].Controls[0]; if (r.Checked) { return(r.Value); } } return(string.Empty); }
public void DefaultProperties() { HtmlInputRadioButton rb = new HtmlInputRadioButton(); Assert.AreEqual(defaultAttributesCount, rb.Attributes.Count, "Attributes.Count"); Assert.IsFalse(rb.Checked, "Checked"); Assert.AreEqual(String.Empty, rb.Name, "Name"); Assert.IsNull(rb.Value, "Value"); Assert.AreEqual("input", rb.TagName, "TagName"); Assert.AreEqual(defaultAttributesCount, rb.Attributes.Count, "Attributes.Count-2"); }
private void SetBoolSelection(bool?boolen, HtmlInputRadioButton trueRB, HtmlInputRadioButton falseRB) { if (boolen.HasValue) { if (boolen.Value) { trueRB.Checked = true; } else { falseRB.Checked = true; } } }
public static int GetSelectedGridItemID(GridView grid, string selectedPosition) { string code = ""; if (selectedPosition != "") { HtmlInputRadioButton rdoItem = (HtmlInputRadioButton)grid.Rows[Convert.ToInt32(selectedPosition)].FindControl("rdoItem"); Literal litValue = (Literal)grid.Rows[Convert.ToInt32(selectedPosition)].FindControl("litValue"); code = litValue.Text; } return Convert.ToInt32(code); }
/// <summary> /// Selects which items to display in the widget designer /// </summary> /// <param name="position">Position of the checkbox defining which items to display</param> public void SelectWhichItemsToDisplay(int position) { HtmlDiv optionsDiv = EM.Widgets .WidgetDesignerContentScreen .WhichItemsToDisplayList .AssertIsPresent("Which items to display options list"); List <HtmlDiv> itemsDivs = optionsDiv.Find.AllByExpression <HtmlDiv>("tagname=div", "class=radio").ToList <HtmlDiv>(); HtmlInputRadioButton optionButton = itemsDivs[position].Find.ByExpression <HtmlInputRadioButton>("tagname=input") .AssertIsPresent("Which items to display option radio button"); optionButton.Click(); }
protected void Guardar(object sender, EventArgs e) { phGuardar.Visible = true; Double totalSi = 0; Double totalNo = 0; for (int i = 1; i <= 36; i = i + 2) { HtmlInputRadioButton miradio1 = (HtmlInputRadioButton)panel1.FindControl("radio" + i); HtmlInputRadioButton miradio2 = (HtmlInputRadioButton)panel1.FindControl("radio" + (i + 1)); if (miradio1.Checked == true) { totalSi++; } if (miradio2.Checked == true) { totalNo++; } } lbTotalSi.Text = "" + totalSi; lbTotalNo.Text = "" + totalNo; Double[] valores = { totalSi, totalNo }; Double porcentaje = Math.Round(((totalNo * 100) / (totalSi + totalNo)), 2); lbObservaciones.Text = "El porcentaje de riesgo indican condiciones de trabajo que pueden estar asociadas a " + "alto riesgo de lesión o enfermedad es de: " + porcentaje + "%"; encuesta_politica nuevo = new encuesta_politica() { id_trabajador = Convert.ToInt32(ddlTrabajador.SelectedValue), fecha = DateTime.Now, si = (100 - porcentaje), no = porcentaje, tipo = "Conocimiento Objetivos PoliticaSST" }; ObjUsuario.Error = CRUD.Add_Fila(nuevo); if (ObjUsuario.Error) { Response.Redirect(Paginas.index_Encuesta_PoliticaSST.Value); } }
protected void btnOK_Click(object sender, EventArgs e) { foreach (Control ctl in formPanel.Controls) { if (ctl is HtmlInputRadioButton) { HtmlInputRadioButton radioButton = (HtmlInputRadioButton)ctl; if (radioButton.Checked) { base.ChangeTheme(radioButton.Value); break; } } } }
private bool?GetBoolSelection(HtmlInputRadioButton trueRB, HtmlInputRadioButton falseRB) { if (trueRB.Checked) { return(true); } else if (falseRB.Checked) { return(false); } else { return(null); } }
public void TelerikTestStudioFrameworkBasicActions() { manager.ActiveBrowser.NavigateTo("http://automatetheplanet.com/healthy-diet-menu-generator/"); HtmlInputSubmit generateButton = manager.ActiveBrowser.Find.ByName <HtmlInputSubmit>("_ninja_forms_field_28"); HtmlInputCheckBox additionalSugarCheckbox = manager.ActiveBrowser.Find.ById <HtmlInputCheckBox>("ninja_forms_field_18"); HtmlInputText firstNameTextInput = manager.ActiveBrowser.Find.ByXPath <HtmlInputText>("//*[@id='ninja_forms_field_23']"); HtmlSelect burgersSelect = manager.ActiveBrowser.Find.ByName <HtmlSelect>("ninja_forms_field_21"); HtmlInputRadioButton coffeeRadioButton = manager.ActiveBrowser.Find.ByExpression <HtmlInputRadioButton>("value=^1 x Trenta"); coffeeRadioButton.Check(isChecked: true, invokeOnChange: true, invokeOnClickChanged: true); burgersSelect.SelectByText("10 x Double Cheeseburgers"); firstNameTextInput.Text = "Anton"; additionalSugarCheckbox.Check(isChecked: true, invokeOnChange: true, invokeOnClickChanged: true); generateButton.Click(); }
public void RenderAsControl(Option baseOption, PlaceHolder ph, string prefix = null) { foreach (var o in baseOption.Items) { ph.Controls.Add(new LiteralControl(" <label class=\"CreateOrderChoicelabel\">")); if (!o.IsLabel) { var rb = new HtmlInputRadioButton(); rb.ClientIDMode = ClientIDMode.Static; rb.ID = "opt" + prefix + o.Bvin.Replace("-", string.Empty); rb.Name = "opt" + prefix + baseOption.Bvin.Replace("-", string.Empty); rb.Attributes["class"] = "hcIsOption radio" + baseOption.Bvin.Replace("-", string.Empty); rb.Value = o.Bvin.Replace("-", string.Empty); ph.Controls.Add(rb); } ph.Controls.Add(new LiteralControl(" " + o.Name + " </label> <br /> ")); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { foreach (Control ctl in formPanel.Controls) { if (ctl is HtmlInputRadioButton) { HtmlInputRadioButton radioButton = (HtmlInputRadioButton)ctl; if (string.Compare(radioButton.Value, Theme, true) == 0) { radioButton.Checked = true; break; } } } } }
protected void Page_Load(object sender, EventArgs e) { List <LookupItemView> screeningQuestions = lookupManager.GetLookItemByGroup("GBVAssessment"); if (screeningQuestions != null && screeningQuestions.Count > 0) { foreach (var screeningQuestion in screeningQuestions) { HtmlTableRow row = new HtmlTableRow(); HtmlTableCell cell1 = new HtmlTableCell(); HtmlTableCell cell2 = new HtmlTableCell(); cell1.Align = "left"; cell2.Align = "left"; List <LookupItemView> responses = lookupManager.GetLookItemByGroup("YesNo"); foreach (var k in responses) { HtmlInputRadioButton radioButton = new HtmlInputRadioButton { ID = string.Format("|{0}|{1}", screeningQuestion.ItemId.ToString(), k.ItemId.ToString()), Name = screeningQuestion.ItemName, Value = k.ItemId.ToString(), }; radioButton.Attributes.Add("data-parsley-required", "True"); radioButton.Attributes.Add("itemid", screeningQuestion.ItemId.ToString()); HtmlGenericControl label = new HtmlGenericControl("label"); label.InnerHtml = string.Format("{0}", k.ItemName); cell2.Controls.Add(label); cell2.Controls.Add(radioButton); } cell1.InnerHtml = screeningQuestion.ItemDisplayName; row.Cells.Add(cell1); row.Cells.Add(cell2); tblGbvScreeningQuestions.Rows.Add(row); } } }
private void AddLayerToLegend(string mapTabId, List<CommonLayer> configuredLayers, List<LayerProperties> layerProperties, HtmlGenericControl container, CommonLayer layer) { int i = configuredLayers.IndexOf(layer); if (i < 0) { return; } int tileWidth = AppSettings.SwatchTileWidth; int tileHeight = AppSettings.SwatchTileHeight; bool expanded = AppSettings.LegendExpanded; HtmlGenericControl legendEntry = new HtmlGenericControl("div"); container.Controls.Add(legendEntry); legendEntry.Attributes["class"] = "LegendEntry"; HtmlGenericControl legendHeader = new HtmlGenericControl("div"); legendEntry.Controls.Add(legendHeader); legendHeader.Attributes["class"] = "LegendHeader"; HtmlGenericControl expander = new HtmlGenericControl("span"); legendHeader.Controls.Add(expander); expander.Attributes["class"] = "LegendExpander " + (expanded ? "Expanded" : "Collapsed"); if (layerProperties[i].CheckMode != CheckMode.None) { HtmlGenericControl visibility = new HtmlGenericControl("span"); legendHeader.Controls.Add(visibility); visibility.Attributes["class"] = "LegendVisibility"; if (layerProperties[i].CheckMode != CheckMode.Empty) { HtmlControl check = null; if (layerProperties[i].IsExclusive) { HtmlInputRadioButton radio = new HtmlInputRadioButton(); radio.Checked = layerProperties[i].CheckMode == CheckMode.Checked; radio.Name = String.Format("{0}_{1}", mapTabId, layer.Parent.ID); check = radio; } else { HtmlInputCheckBox checkBox = new HtmlInputCheckBox(); checkBox.Checked = layerProperties[i].CheckMode == CheckMode.Checked; check = checkBox; } visibility.Controls.Add(check); check.Attributes["class"] = "LegendCheck"; check.Attributes["data-layer"] = layerProperties[i].Tag; } } HtmlGenericControl name = new HtmlGenericControl("span"); legendHeader.Controls.Add(name); name.Attributes["class"] = "LegendName"; if (!String.IsNullOrEmpty(layerProperties[i].MetaDataUrl)) { HtmlAnchor a = new HtmlAnchor(); name.Controls.Add(a); a.HRef = layerProperties[i].MetaDataUrl; a.Target = "metadata"; a.InnerText = layerProperties[i].Name; a.Attributes["class"] = "LegendMetadata"; } else { name.InnerText = layerProperties[i].Name; } HtmlGenericControl content = new HtmlGenericControl("div"); content.Attributes["class"] = "LegendContent"; content.Style["display"] = expanded ? "block" : "none"; switch (layer.Type) { case CommonLayerType.Group: if (layer.Children != null) { foreach (CommonLayer childLayer in layer.Children) { AddLayerToLegend(mapTabId, configuredLayers, layerProperties, content, childLayer); } } break; case CommonLayerType.Feature: int layerIndex = layer.DataFrame.Layers.IndexOf(layer); if (layer.Legend != null) { int n = 0; string escapedMapTabId = Server.UrlEncode(mapTabId); for (int g = 0; g < layer.Legend.Groups.Count; ++g) { int classCount = layer.Legend.Groups[g].Classes.Count; for (int c = 0; c < classCount; ++c) { if (!layer.Legend.Groups[g].Classes[c].ImageIsTransparent) { HtmlGenericControl legendClass = new HtmlGenericControl("div"); content.Controls.Add(legendClass); legendClass.Attributes["class"] = "LegendClass"; HtmlGenericControl legendSwatch = new HtmlGenericControl("span"); legendClass.Controls.Add(legendSwatch); legendSwatch.Attributes["class"] = "LegendSwatch"; legendSwatch.Style["background"] = String.Format("transparent url(CompiledSwatch.ashx?maptab={0}&c={1}) no-repeat scroll -{2}px -{3}px", escapedMapTabId, AppContext.ConfigurationKey, tileWidth * layerIndex, tileHeight * n); using (MemoryStream stream = new MemoryStream(layer.Legend.Groups[g].Classes[c].Image)) { using (Bitmap swatch = new Bitmap(stream)) { legendClass.Style["height"] = String.Format("{0}px", swatch.Height); legendSwatch.Style["width"] = String.Format("{0}px", swatch.Width); legendSwatch.Style["height"] = String.Format("{0}px", swatch.Height); } } if (classCount > 1 || layer.Legend.Groups.Count > 1) { HtmlGenericControl className = new HtmlGenericControl("span"); legendClass.Controls.Add(className); className.Attributes["class"] = "LegendClassName"; className.InnerText = layer.Legend.Groups[g].Classes[c].Label; } } n += 1; } } } break; case CommonLayerType.Annotation: if (layer.Children != null) { foreach (CommonLayer childLayer in layer.Children) { AddLayerToLegend(mapTabId, configuredLayers, layerProperties, content, childLayer); } } break; } if (content.Controls.Count == 0) { expander.Attributes["class"] = "LegendExpander Empty"; } else { legendEntry.Controls.Add(content); } }