i have a textbox which is associated to radiobutton list. if i checked first radio button then textbox should validate and if i checked second radio button then textbox should validate.

Ravi Teja 1 Reputation point
2022-09-16T10:25:25.25+00:00

<asp:Radiobuttonlist id="search" runat="server" repeatcolumns="4" reapeatdirection="horizontal" onselectedindexchanged="search_selectedindexchanged">
<asp:listitem selected="true">c1</asp;listitem>
<asp:listitem >c2</asp;listitem>
<asp:listitem >c3</asp;listitem>
<asp:listitem >c4</asp;listitem>
</asp:Radiobuttonlist>
<input type="text" name="search" runat="server" id="txtsearch" Placeholder="c1"/>
<asp:button id="btnsearch" runat="server"/>

cs code:
protected void search_selectedindexchanged(object sender, EventArgs e)
{
txtsearch.value="";
if(search.selecteditem.text=="c1"
{
txtsearch.attributes.add("placeholder","enter c1");
}
if(search.selecteditem.text=="c2"
{
txtsearch.attributes.add("placeholder","enter c2");
}
if(search.selecteditem.text=="c3"
{
txtsearch.attributes.add("placeholder","enter c3");
}
if(search.selecteditem.text=="c4"
{
txtsearch.attributes.add("placeholder","enter c4");
}
}

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,451 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,820 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.