Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7185693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:28:17+00:00 2026-05-28T18:28:17+00:00

My Aspx markup is as follows. The visitor may select the answer by choosing

  • 0

My Aspx markup is as follows.
The visitor may select the answer by choosing the “winning question” radiobutton

The HiddenFields contain True or False

So if the user selects the rdAnsBool1 and the value of the HiddenField1 is “True”,
the JQuery should add a “correct” CSS class to the parent div with ID = Answer

If the user selects the rdAnsBool1 and the value of the HiddenField1 is “False”, the JQuery should add a “wrong” CSS class to the parent div with ID = Answer

<div id="Answer" class="Ans">
   <div id ="Left"> 
   <asp:RadioButton ID="rdAnsBool1" runat="server" Text = '<%# DataBinder.Eval(Container.DataItem, "Ans1") %>' />
   <asp:RadioButton ID="rdAnsBool2" runat="server" Text = '<%# DataBinder.Eval(Container.DataItem, "Ans2") %>' />
   <asp:HiddenField ID="HiddenField1" runat="server" Value = '<%# DataBinder.Eval(Container.DataItem, "Ans1Bool") %>'/>
   <asp:HiddenField ID="HiddenField2" runat="server" Value = '<%# DataBinder.Eval(Container.DataItem, "Ans2Bool") %>'/>
   </div>
</div>

How can this be with JQuery?

Update.
The Answer div is located within a Listview. This is the reason i would like to paint the parent div.

Just another Update
I am afraid of JQuery…

The markup has changed to the following… for this reason i offer 200 boundy for the winning solution.

<div id="Answer" class="Ans">
           <div id ="Left"> 
           <asp:RadioButton ID="rdAnsBool1" runat="server" Text = '<%# DataBinder.Eval(Container.DataItem, "Ans1") %>' />
           <asp:RadioButton ID="rdAnsBool2" runat="server" Text = '<%# DataBinder.Eval(Container.DataItem, "Ans2") %>' />
           <asp:RadioButton ID="rdAnsBool3" runat="server" Text = '<%# DataBinder.Eval(Container.DataItem, "Ans3") %>' />
           <asp:RadioButton ID="rdAnsBool4" runat="server" Text = '<%# DataBinder.Eval(Container.DataItem, "Ans4") %>' />
           <asp:RadioButton ID="rdAnsBool5" runat="server" Text = '<%# DataBinder.Eval(Container.DataItem, "Ans5") %>' />
           <asp:RadioButton ID="rdAnsBool6" runat="server" Text = '<%# DataBinder.Eval(Container.DataItem, "Ans6") %>' />
           <asp:HiddenField ID="HiddenField1" runat="server" Value = '<%# DataBinder.Eval(Container.DataItem, "Ans1Bool") %>'/>
           <asp:HiddenField ID="HiddenField2" runat="server" Value = '<%# DataBinder.Eval(Container.DataItem, "Ans2Bool") %>'/>
           <asp:HiddenField ID="HiddenField3" runat="server" Value = '<%# DataBinder.Eval(Container.DataItem, "Ans3Bool") %>'/>
           <asp:HiddenField ID="HiddenField4" runat="server" Value = '<%# DataBinder.Eval(Container.DataItem, "Ans4Bool") %>'/>
           <asp:HiddenField ID="HiddenField5" runat="server" Value = '<%# DataBinder.Eval(Container.DataItem, "Ans5Bool") %>'/>
           <asp:HiddenField ID="HiddenField6" runat="server" Value = '<%# DataBinder.Eval(Container.DataItem, "Ans6Bool") %>'/>
           </div>
        </div>

And here is the JsFiddle part

http://jsfiddle.net/VTevz/

This thing is driving me nuts

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:28:18+00:00Added an answer on May 28, 2026 at 6:28 pm
    // get a reference to radio button and attach change handler
    $('input[id*="rdAnsBool"]').change(function(){
         var container = $(this).closest('div.Ans'),
             questionid = $(this).attr('id'),
             index = questionid[questionid.indexOf('rdAnsBool') + 1];
    
         // test for condition and set classes accordingly ...
         if($(this).val() == $(this).parent()
                                    .find('input[id*="HiddenField' + index + '"]').val()) {
              container.addClass('correct').removeClass('wrong');
              return;
         }
    
         container.addClass('wrong').removeClass('correct');
    });
    

    Update (Make sure you post the HTML markup and not ASP markup when working in the browser context):

    http://jsfiddle.net/VTevz/7/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my full markup: <%@page Title= Language=VB MasterPageFile=~/Master Pages/MasterPage.master AutoEventWireup=false CodeFile=Statistics.aspx.vb Inherits=Statistics %> <%@
I have a form in my aspx markup. I add to it some fields
Is there a way to include some aspx/ascx markup in a DLL and use
Is there a way to comment out markup in an .ASPX page so that
Mark Up <%@ Page Language=C# AutoEventWireup=true CodeBehind=test.aspx.cs Inherits=Zuhaib.test %> <!-- Put IE into quirks
Environment: .NET 2.0, visual studio 2005 in aspx markup, set a control like: <asp:CheckBox
On an Aspx page, I have this markup (setup for a jQuery UI dialog):
Ok, stupid question and I don't think it's possible but, I have this markup
I'm displaying a GridView using the following markup in my default.aspx : <Columns> <asp:BoundField
I have the following markup in a DataGrid: <itemtemplate> <a href='~/File.aspx?item=<%# DataBinder.Eval(Container.DataItem, ItemID).ToString() %>'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.