Solved

Validating textbox when user clicks Yes in radiobutton

Posted on 2010-08-25
1
430 Views
Last Modified: 2012-05-10
I have a repeater. In it, I have a radiobutton list and a textbox.

Radiobutton list has "Yes" and "No". If user clicks "Yes", they have to enter something in the textbox. They can't leave it empty.

I don't think a requiredfieldvalidator would work here. How can I do this??
<asp:Repeater runat="server" OnItemDataBound="rpQuestions_OnItemDataBound"   ID="rpQuestions">
              <ItemTemplate>
              <tr>
              <td>
                <asp:Label runat="server" ID="lblId" Visible="false" Text='<%# DataBinder.Eval(Container.DataItem, "QuestionId") %>'></asp:Label>
              </td>
              
               <td  align="right">
               
                
                 <asp:RadioButtonList   runat="server" ID="rbQuestions"  TextAlign="Right" RepeatDirection="Horizontal">
                   <asp:ListItem Value="Y"  Text="Yes"></asp:ListItem>
                   <asp:ListItem Value="N" Text="No"></asp:ListItem>
                 </asp:RadioButtonList>
               
                   
                 <asp:RequiredFieldValidator ID="RequiredFieldValidator10" Display="Dynamic" ControlToValidate="rbQuestions" ErrorMessage="Employment Questions" Text="*" runat="server"></asp:RequiredFieldValidator>     
               
                </td>
              </tr>
              <tr>
              <td></td>
              <td><asp:Label ID="lblExplain" Text='<%# DataBinder.Eval(Container.DataItem, "Explain") %>' runat="server" ></asp:Label></td>
               <td>
                 <asp:TextBox runat="server"   ID="txtExplanation"  TextMode="MultiLine"></asp:TextBox>
               </td>
              </tr>
            </ItemTemplate>
        </asp:Repeater>

Open in new window

0
Comment
Question by:Camillia
1 Comment
 
LVL 16

Accepted Solution

by:
Vikram Singh Saini earned 500 total points
ID: 33525450
Hi,

There is a property named ValidateEmptyText for custom validation of textbox. More details on link: http://quickstarts.asp.net/QuickStartv20/aspnet/doc/validation/default.aspx#validateemptytext

Regards,
VSS

0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question