Solved

Validating textbox when user clicks Yes in radiobutton

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

19 Experts available now in Live!

Get 1:1 Help Now