I am building a list of questions with controls. One of the question returns with a radiobutton list, that when the user selects "other" a textbox will display for them to enter in additional information. I must be missing something, when I debug it looks like the textbox should work fine however the textbox never shows up... can somone help me to see what i am missing? My guess is that I somehow need to add this new textbox I am building to the AjaxManager ( if so can someone show me how to do this ? )...
I would have thought it would be ok as it is in the Placeholder that is already in the AjaxManager ?
here is the class:
public
partial class Tools_Workforce_OUT_PulseSurveyQuestions : EDCC.PageBase
{
private string _login = string.Empty;
private string _user = string.Empty;
private string _location = string.Empty;
private string _roll = string.Empty;
private string _sup = string.Empty;
string surveyType = "Video";
protected override void Page_Load(object sender, EventArgs e)
{
// Use to get user info from Active diretory
ActiveDirectoryBase ad = new ActiveDirectoryBase(User.Identity.Name.Split('\\')[1]);
base.lblMaster("PageName", "~/Tools/Workforce/OUT_PulseSurveyQuestions.aspx");
base.lblMaster("LastMod", "06/11/2009");
base.lblMaster("lblHeader", "Pulse Survey");
base.showMasterControl("pnlFooterLinks", base.m_CharterBase.GetSiteKey("ShowFooterLinks"));
base.showMasterControl("pnlUserInfo", "false");
base.showMasterControl("pnlMenu", "false");
(EDCC.User)Master.curUser = (EDCC.User)base.curUser();
// assign user info from Active diretory
_login = ad.DomainLogin;
_user = ad.DisplayName;
_location = ad.Location == string.Empty ? ad.Department : ad.Location;_roll = ad.Title;
_sup = ad.Supervisor.FullName;
Page.Header.Title = "Pulse Survey";
//surveyType = Request.QueryString["Type"];
lblPageTitle.Text = surveyType + " Pulse Survey ";if (!Page.IsPostBack)
{
GetPLSS_State();
//GetQuestions();
}
base.Page_Load(sender, e);
}
// questions & controls stay if there is a postback
protected override void OnInit(EventArgs e)
{
base.OnInit(e);GetQuestions();
}
#region DropDownsprivate void GetPLSS_State()
{
CharterBaseNew db = new CharterBaseNew("EDCCConnectString");
DataSet ds = db.ExecuteDataSet("PLSS_GetState", CommandType.StoredProcedure, CharterBaseNew.DbConnectionState.CloseOnExit);int i = ds.Tables.Count;
ddlState.DataSource = ds.Tables[0];
ddlState.DataTextField =
"State";
ddlState.DataValueField = "State";
ddlState.DataBind();
ddlState.Items.Insert(0, new RadComboBoxItem("** Pick A State **"));}
private void GetPLSS_City(){
CharterBaseNew db = new CharterBaseNew("EDCCConnectString");db.AddParameter(
"@State", ddlState.SelectedValue);
DataSet ds = db.ExecuteDataSet("PLSS_GetCity", CommandType.StoredProcedure, CharterBaseNew.DbConnectionState.CloseOnExit);int i = ds.Tables.Count;
ddlCity.DataSource = ds.Tables[0];
ddlCity.DataTextField =
"City";
ddlCity.DataValueField = "City";
ddlCity.DataBind();
ddlCity.Items.Insert(0, new RadComboBoxItem("** Pick A City **"));}
// show only cities in that state
protected void ddlState_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
{
lblCity.Visible = true;ddlCity.Visible = true;GetPLSS_City();
}
// to find out if other is selected, show textbox
protected void ddlCity_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
{
if (ddlCity.SelectedValue == "Other"){
txtOther.Visible = true;lblOther.Visible = true;}
else
{
txtOther.Visible = false;lblOther.Visible = false;}
}
#endregion
//BUILD THE CONTROLS FROM THE LIST OF QUESTIONS
public void GetQuestions()
{
foreach (PulseSurveyQuestions q in PulseSurveyQuestions.getQuestions(surveyType)){
string refType = q.RefListType;
// creates an HTML line break
HtmlGenericControl lineBreak = new HtmlGenericControl("br");
//builds questions
Label lblquestion = new Label();
lblquestion.ID =
"lblquestion" + surveyType + q.QuestionID;
lblquestion.Text = q.Question + "<br/>";
lblquestion.CssClass =
"LblName";
lblquestion.EnableViewState = true;
ph1.Controls.Add(lblquestion);
//builds Radiobutton list based on surveyType (ie: video, HSI, phone)
// and based on ControlType
if (q.ControlType == PulseSurveyQuestionTypes.RadioButtonList)
{
RadioButtonList rbl = new RadioButtonList();rbl.ID =
"rbl" + surveyType + q.QuestionID;
rbl.CssClass = "LblName";
rbl.Font.Size = 11;
rbl.DataSource = DataGateway.Instance.GetList(refType).Tables[0];rbl.DataTextField =
"DisplayText";
rbl.DataValueField = "ValueText";
rbl.DataBind();
rbl.AutoPostBack = true;rbl.EnableViewState = true;ph1.Controls.Add(rbl);
ph1.Controls.Add(lineBreak);
rbl.SelectedIndexChanged += new EventHandler(rbl_SelectedIndexChanged);}
//builds a textbox based on controlType
else if (q.ControlType == PulseSurveyQuestionTypes.TextBox)
{
TextBox txt = new TextBox();txt.ID =
"txt" + surveyType + q.QuestionID;
txt.CssClass = "LblName";
txt.Font.Size = 11;
txt.Width = 300;
txt.EnableViewState = true;ph1.Controls.Add(txt);
ph1.Controls.Add(lineBreak);
}
//builds a radiobutton list based on controlType (yes/no)
else if (q.ControlType == PulseSurveyQuestionTypes.YesNoRadio)
{
RadioButtonList rblYesNo = new RadioButtonList();rblYesNo.ID =
"rbl" + surveyType + q.QuestionID;
rblYesNo.CssClass = "LblName";
rblYesNo.DataSource =
DataGateway.Instance.GetList(refType).Tables[0];
rblYesNo.DataTextField = "DisplayText";rblYesNo.DataValueField = "ValueText";
rblYesNo.DataBind();
rblYesNo.EnableViewState = true;ph1.Controls.Add(rblYesNo);
ph1.Controls.Add(lineBreak);
}
//builds a dropdown based on controlType
else if (q.ControlType == PulseSurveyQuestionTypes.DropDown)
{
RadComboBox ddl = new RadComboBox();ddl.ID =
"ddl" + surveyType + q.QuestionID;
ddl.Skin = "WebBlue";
ddl.DataSource =
DataGateway.Instance.GetList(refType).Tables[0];
ddl.DataTextField = "DisplayText";ddl.DataValueField = "ValueText";
ddl.DataBind();
ddl.Items.Insert(0,
new RadComboBoxItem("** Box Type **"));
ddl.CssClass = "LblName";ddl.EnableViewState = true;
ph1.Controls.Add(ddl);
ph1.Controls.Add(lineBreak);
}
//builds a textbox with an add button based on controlType
// this is for account number
else if (q.ControlType == PulseSurveyQuestionTypes.TextBoxAddToList)
{
TextBox txtAdd = new TextBox();txtAdd.ID =
"txtAdd" + surveyType + q.QuestionID;
txtAdd.CssClass = "LblName";
txtAdd.Font.Size = 11;
txtAdd.EnableViewState = true;ph1.Controls.Add(txtAdd);
ph1.Controls.Add(lineBreak);
// add button to add another textbox
Button bt = new Button();
bt.ID =
"btAdd";
bt.Text = "Add another account";
ph1.Controls.Add(bt);
}
//builds a multiLine textbox based on controlType
else if (q.ControlType == PulseSurveyQuestionTypes.multiTextBox)
{
TextBox txtMulti = new TextBox();txtMulti.ID =
"txtMulti" + surveyType + q.QuestionID;
txtMulti.CssClass = "LblName";
txtMulti.Font.Size = 11;
txtMulti.TextMode = TextBoxMode.MultiLine;txtMulti.Width = 300;
txtMulti.Height = 100;
txtMulti.EnableViewState = true;ph1.Controls.Add(txtMulti);
ph1.Controls.Add(lineBreak);
}
}
}
// will build a textbox when "Other" or "Error code on Box") is selected
protected void rbl_SelectedIndexChanged(object sender, EventArgs e)
{
RadioButtonList rdbl = (RadioButtonList)sender;if (rdbl != null){
if (surveyType == "Video"){
if ((rdbl.Text == "Other") || (rdbl.Text == "Error code on Box")){
TextBox txtOther = new TextBox();
txtOther.ID = "txtRblOther";txtOther.CssClass = "LblName";
txtOther.Font.Size = 11;
ph1.Controls.Add(txtOther);
}
}
}
}
protected override void LoadViewState(object savedState){
base.LoadViewState(savedState);}
}
here is the front end :
<table>
<tr>
<td colspan="2" height="35px">
<asp:Label ID="Label1" runat="server" Text="What area are you receiving calls from in the last 10-15 mins?"
CssClass="LblName"></asp:Label>
</td>
</tr>
<tr >
<td valign="top">
<asp:Label ID="lblState" runat="server" Text="State" Width="25px" CssClass="LblName"></asp:Label>
</td>
<td>
<telerik:RadComboBox ID="ddlState" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlState_SelectedIndexChanged"
Skin="WebBlue">
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
<ExpandAnimation Type="OutQuart"></ExpandAnimation>
</telerik:RadComboBox>
<asp:Label ID="lblOther" runat="server" Text="Please enter in the missing city."
Style="z-index: 106; left: 190px; position: relative; top: -5px;" CssClass="LblName"
Font-Size="Small" Visible="False" ></asp:Label>
</td>
</tr>
<tr>
<td valign="top">
<asp:Label ID="lblCity" runat="server" Text="City" Width="25px" CssClass="LblName"
Visible="false"></asp:Label>
</td>
<td>
<telerik:RadComboBox ID="ddlCity" runat="server" Skin="WebBlue" Visible="False" OnSelectedIndexChanged="ddlCity_SelectedIndexChanged"
AutoPostBack="True"
ToolTip="Please select Other if you cannot find the city your looking for.">
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
<ExpandAnimation Type="OutQuart"></ExpandAnimation>
</telerik:RadComboBox>
<asp:TextBox ID="txtOther" runat="server" Visible="false" Style="z-index: 104; left: 190px;
position: relative; top: -20px;"></asp:TextBox>
</td>
</tr>
</table>
<br />
<asp:PlaceHolder id="ph1" runat="server"></asp:PlaceHolder>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="ddlState">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="ddlState" LoadingPanelID="RadAjaxLoadingPanel1" />
<telerik:AjaxUpdatedControl ControlID="lblCity" />
<telerik:AjaxUpdatedControl ControlID="ddlCity" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="ddlCity">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="lblOther" />
<telerik:AjaxUpdatedControl ControlID="txtOther"
LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="ph1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="ph1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
</
asp:Content>