Solved

Validating textbox when user clicks Yes in radiobutton

Posted on 2010-08-25
1
428 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now