Solved

help with user control behavior

Posted on 2014-02-03
5
496 Views
Last Modified: 2014-02-24
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.
radiobutton user control
<%@ 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


textbox user control
 <%@ 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.
0
Comment
Question by:hougie40
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 

Author Comment

by:hougie40
ID: 39832702
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

0
 

Author Comment

by:hougie40
ID: 39832901
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.

alert
0
 

Author Comment

by:hougie40
ID: 39833027
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



alert
0
 
LVL 11

Accepted Solution

by:
Mihai Stancescu earned 500 total points
ID: 39834900
Hi,

1. You can use a server-side event on the custom control with the radio buttons (this resulting in a trip to the server for every radio change)
2. You can use jQuery to hide the controls after you get the value just as you did in the previous posts
3. You can use a client side javascript framework like Knockout, AngularJS, etc..


Regards,
Mishu
0
 

Author Closing Comment

by:hougie40
ID: 39883926
Thank you
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

627 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