Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hey Everyone,

i have the below input radio button configuration, and in my code behind if a value is set to true, i want to hide on of them. Any help would be great

ASP.NET
<asp:Panel ID="pnlAd" runat="server">
               <input id="Prior" name="rblAd" type="radio" value="-2" class="s2"
                    önclick='rblAd_onClick(event);' />
               <asp:Label ID="lblPriorAd" runat="server" CssClass="s1" Text="Prior Ad">
               <input id="Current"  name="rblAd" type="radio" value="-1" class="s2"
                    önclick='rblAd_onClick(event);' /><asp:Label ID="lblCurrentAd" runat="server" CssClass="s1"
                       Text="Current Ad & Print">
               <input id="Next"  name="rblAd" type="radio" value="0" class="s2"
                    önclick='rblAd_onClick(event);' /><asp:Label ID="lblThisAd" runat="server" CssClass="s1"
                       Text="Next Ad">
               <input id="Future"  name="rblAd" type="radio" value="1" class="s2"
                    önclick='rblAd_onClick(event);' /><asp:Label ID="lblNextAd" runat="server" CssClass="s1"
                       Text="Ad Prep">
                 <br /><asp:Label ID="lblDateFrom" runat="server" CssClass="s1" Text="Ad From">
Posted
Updated 23-Oct-13 8:56am
v2
Comments
Sergey Alexandrovich Kryukov 23-Oct-13 15:43pm    
On what event do you want to hide/show the element? What's the problem? http://www.whathaveyoutried.com so far and where did you stuck?
—SA
bobb024 23-Oct-13 15:47pm    
Hello Sergey,

I am trying to in the C# code behind when a local variable is set to true, hide the input radio button with the ID of "Future"

so something of the variation of

bool hfWOP = true;
hfWOP = Return Value of manager;
if (hfWOP == true)
//set future button display to none, ie hide it
bjdestiny 24-Oct-13 4:57am    
why don't you try the separate css code for each button.??

1 solution

Write a function in design side in Javascript which takes the hardcoded id of that control which you wants to make invisible.

and from the codebehind call that function with your desired id.

like from code behind.


C#
if(value)
{
 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "blah", "makeInvisible('" + parm + "');", true);

}



here param is the parameter in which you have to pass radiobutton id as parameter, and makeInvisible() is the Javascript function which will take Radiobutton id and will disable it.

Hope this will help. :)
 
Share this answer
 
v2
Comments
bobb024 24-Oct-13 15:22pm    
awesome, thank you!
VICK 25-Oct-13 0:34am    
Glad to help you.. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900