change textbox through dropdown list c# [closed]

katobit

New Member
Requirement:fulfill with a different sentence a textbox depending on the choice of an dropdownlist. but when I choose one "x" value of the ddlist, the textbox must appear empty and is mandatory to the user write something.My problem is even I write something... When I save the form... one control that i make say me "you text box must not be empty"here some code:\[code\] protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { getPermissions(); setBeginingdata(); //in the setBeginingdata() method, the setTxtObs() is called too. } setTxtObs(); void setTxtObs() { if (ddmotivo.SelectedItem.Text.Contains("Others")) txtObservacoes.Text = ""; else if (!ddmotivo.SelectedItem.Text.Contains("Others")) { StringBuilder sbObs = new StringBuilder(); sbObs.AppendFormat("The employer {0} missed because ({1})", getDrUser( ["Sigla"].ToString(), ddmotivo.SelectedItem.ToString().Trim()); txtObs.Text = sbObs.ToString(); } }\[/code\]
 
Back
Top