Link to home
Start Free TrialLog in
Avatar of Steve Hougom
Steve HougomFlag for United States of America

asked on

help with user control behavior

I have a main page that is an ascx user control and also has two sections that are user controls.  I need to be able to hide/show controls in one user control section based on the radio button choice of another user control section.  

The main page code is below it contains 2 user controls.

<%@ Control Language="c#" AutoEventWireup="false" Codebehind="WCNewClaim.ascx.cs" 
<%@ Register TagPrefix="uc1" TagName="WCHeaderInfo" Src="../Controls/WCHeaderInfo.ascx" %>
<%@ Register TagPrefix="uc1" TagName="WCEmployeeOccupation" Src="../Controls/WCEmployeeOccupation.ascx" %>

<TABLE id="Table1" cellSpacing="0" cellPadding="0" border="0">
	<TR>
		<TD><uc1:wcheaderinfo id="WCHeaderInfo1" runat="server"></uc1:wcheaderinfo></TD>
	</TR>
	
	<TR>
		<TD><uc1:wcemployeeoccupation id="WCEmployeeOccupation1" runat="server"></uc1:wcemployeeoccupation></TD>
	</TR>
</TABLE>

Open in new window


The user control sections are below.  RadiobuttonList.  When they click GL radio button I need to be able to hide or show textboxes in section two.
User generated image
<%@ Control Language="c#" AutoEventWireup="false" Codebehind="WCHeaderInfo.ascx.cs" Inherits=
<%@ Register TagPrefix="cc2" Namespace="RTI.WebControls.Safety.RadioButtonList" Assembly="RTIWebControlsSafety" %>


<cc2:safetywctype id="rdlCaseType" runat="server"></cc2:safetywctype>

Open in new window


User generated image
 <%@ Control Language="c#" AutoEventWireup="false" Codebehind="WCEmployeeOccupation.ascx.cs" Inherits="
 <%@ Register TagPrefix="cc7" Namespace="RTI.WebControls.Driver.TextBox" Assembly="RTIWebControlsDriver" %>
 
 
 <cc7:SocialSecurityTextBox id="txtSSN" runat="server"></cc7:SocialSecurityTextBox>

Open in new window


I am not sure how to send values between two user controls hosted on a page that just so happens to be another user control.  My first thought was to use jquery to show or hide controls or perhaps there is another way I am just not sure.

If I need to provide more information to arrive at a solution I can.
Avatar of Steve Hougom
Steve Hougom
Flag of United States of America image

ASKER

So far im able to trap the click at least.

But havent got the value showing in the alert.

  <script src="http://code.jquery.com/jquery.js"></script>
    <script type="text/javascript">
       

        $('#<%= WCHeaderInfo1.rdlCaseType.ClientID %>').change(function () {
           var radioListID = ('<%= WCHeaderInfo1.rdlCaseType.SelectedValue %>');
            alert($(radioListID));
            //alert("hi");
           
        });
    </script>

Open in new window

For example this doesnt even show an alert box.  Im just trying to trap the selection from the radio button list.  And then hide or show a text box elsewhere based on that choice.
But if I replace the alert below with just a simple alert("hi"); it works.
<div runat="server">
    <script src="http://code.jquery.com/jquery.js"></script>
    <script type="text/javascript">
       
        $('#<%= WCHeaderInfo1.rdlCaseType.ClientID %>').click(function () {

            var selectedValue = $('#<%= WCHeaderInfo1.rdlCaseType.SelectedValue%>');
           
            alert(selectedValue);
          
           
        });
    </script>
 </div>

Open in new window


Here is the result.

User generated image
I think I got it now.

<div runat="server">
    <script src="http://code.jquery.com/jquery.js"></script>
    <script type="text/javascript">
       
        $('#<%= WCHeaderInfo1.rdlCaseType.ClientID %>').click(function () {
            
            
            var selectedValue = $('#<%= WCHeaderInfo1.rdlCaseType.ClientID %> input:radio:checked').val();

          
            alert(selectedValue);
          
           
        });
    </script>
 </div>

Open in new window



User generated image
ASKER CERTIFIED SOLUTION
Avatar of Mihai Stancescu
Mihai Stancescu
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you