Accessing usercontrols inside placeholder control using jQuery
-
I have an aspx form which are having three usercontrols (basically 2 sets of radio buttons). All are placed dynamically on page load in a placeholder control. I want to display the other radiobuttons(usercontrols) based on the previous selection. So for eg: If I have three usercontrols, uc1, uc2, uc3 which are all having two sets of radio buttons. uc2 will display only if uc1 is selected and uc3 will display only if uc2 is selected. How can I achieve this through jquery/javascript? All these controls should be loaded and visible should be hidden while loading the page. I googled for sometime, but didn't get any effective result. Could anybody please help. Following is my code:
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Src="~/DI_UserControls/AppForm0602.ascx" TagName="AppForm602" TagPrefix="AppForm602" %>
<%@ Register Src="~/DI_UserControls/AppForm0719.ascx" TagName="AppForm719" TagPrefix="AppForm719" %>
<%@ Register Src="~/DI_UserControls/AppForm0466.ascx" TagName="AppForm466" TagPrefix="AppForm466" %>protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["con1"].ConnectionString.ToString());
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "sp_GetPages";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
cmd.Parameters.AddWithValue("@PageID", 12);
cmd.Parameters.AddWithValue("@ApplicationID", 157);
SqlDataAdapter adpt = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
adpt.Fill(dt);
cmd.CommandText = "sp_GetPageDependency";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@PageID", 12);
SqlDataAdapter adpt1 = new SqlDataAdapter(cmd);
DataTable dt1 = new DataTable();
adpt1. -
I have an aspx form which are having three usercontrols (basically 2 sets of radio buttons). All are placed dynamically on page load in a placeholder control. I want to display the other radiobuttons(usercontrols) based on the previous selection. So for eg: If I have three usercontrols, uc1, uc2, uc3 which are all having two sets of radio buttons. uc2 will display only if uc1 is selected and uc3 will display only if uc2 is selected. How can I achieve this through jquery/javascript? All these controls should be loaded and visible should be hidden while loading the page. I googled for sometime, but didn't get any effective result. Could anybody please help. Following is my code:
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Src="~/DI_UserControls/AppForm0602.ascx" TagName="AppForm602" TagPrefix="AppForm602" %>
<%@ Register Src="~/DI_UserControls/AppForm0719.ascx" TagName="AppForm719" TagPrefix="AppForm719" %>
<%@ Register Src="~/DI_UserControls/AppForm0466.ascx" TagName="AppForm466" TagPrefix="AppForm466" %>protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["con1"].ConnectionString.ToString());
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "sp_GetPages";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
cmd.Parameters.AddWithValue("@PageID", 12);
cmd.Parameters.AddWithValue("@ApplicationID", 157);
SqlDataAdapter adpt = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
adpt.Fill(dt);
cmd.CommandText = "sp_GetPageDependency";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@PageID", 12);
SqlDataAdapter adpt1 = new SqlDataAdapter(cmd);
DataTable dt1 = new DataTable();
adpt1.You have to create an empty container like a set of div tags, in the form or the control, assign an id to it, and use Java-script to write html in the container, creating a new set of radio buttons. So if the DOM detects that the first set of radio buttons was selected, then the JQuery would fire and create a new set based on the result of the first set. I've never seen an example of exactly what you want, but I have written code that does the same thing.
-
I have an aspx form which are having three usercontrols (basically 2 sets of radio buttons). All are placed dynamically on page load in a placeholder control. I want to display the other radiobuttons(usercontrols) based on the previous selection. So for eg: If I have three usercontrols, uc1, uc2, uc3 which are all having two sets of radio buttons. uc2 will display only if uc1 is selected and uc3 will display only if uc2 is selected. How can I achieve this through jquery/javascript? All these controls should be loaded and visible should be hidden while loading the page. I googled for sometime, but didn't get any effective result. Could anybody please help. Following is my code:
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Src="~/DI_UserControls/AppForm0602.ascx" TagName="AppForm602" TagPrefix="AppForm602" %>
<%@ Register Src="~/DI_UserControls/AppForm0719.ascx" TagName="AppForm719" TagPrefix="AppForm719" %>
<%@ Register Src="~/DI_UserControls/AppForm0466.ascx" TagName="AppForm466" TagPrefix="AppForm466" %>protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["con1"].ConnectionString.ToString());
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "sp_GetPages";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
cmd.Parameters.AddWithValue("@PageID", 12);
cmd.Parameters.AddWithValue("@ApplicationID", 157);
SqlDataAdapter adpt = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
adpt.Fill(dt);
cmd.CommandText = "sp_GetPageDependency";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@PageID", 12);
SqlDataAdapter adpt1 = new SqlDataAdapter(cmd);
DataTable dt1 = new DataTable();
adpt1.Each control rendered in an ASP.NET page has a unique ID (that can be queried using
Control.ClientID
) that can be used to access the control from JavaScript (and jQuery). You can set up client side event handlers for the click events of the controls and show/hide other controls using thedisplay
orvisibility
attributes of the DOM element.