Hi,
I am relatively new to designing in ASP and this is my first form. I hav created a RadioButtonList within a FormView and one of the items is an other which, when selected, should pass focus onto a textbox for the user to type their 'other' reply. The code i have so far is...
<asp:RadioButtonList ID="radQuestion" runat="server" SelectedValue='<%# Bind("question") %>'>
<asp:ListItem>Printed Advertising</asp:ListItem>
<asp:ListItem>AEG Website</asp:ListItem>
<asp:ListItem>Broadcast</asp:ListItem>
<asp:ListItem>Radio</asp:ListItem>
<asp:ListItem>Television</asp:ListItem>
<asp:ListItem>Other</asp:ListItem>
</asp:RadioButtonList>
<asp:TextBox ID="txtOther" text='<%# Bind("question") %>' Visible=false runat="server" />
<asp:RequiredFieldValidator ID="requiredQuestion" runat="server" ControlToValidate="question"
ErrorMessage="* Please tell us where you heard about the competition." Display="Dynamic">*</asp:RequiredFieldValidator>
and in the code behind file is...
protected void Page_Load(object sender, EventArgs e)
{
RadioButtonList radQuestion = (RadioButtonList)FormView1.FindControl("radQuestion");
if (radQuestion.Text == "other")
{
TextBox txtOther = (TextBox)FormView1.FindControl("txtOther");
txtOther.Visible = true;
SetFocus(FormView1.FindControl("txtOther"));
}
This is creating a custom user control so there is no form tag to attach a onload attribute to.
Thanks in advance for your reply.
Jason