Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Accessing usercontrols inside placeholder control using jQuery

Accessing usercontrols inside placeholder control using jQuery

Scheduled Pinned Locked Moved ASP.NET
javascriptquestioncsharpsharepointhelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    meeram395
    wrote on last edited by
    #1

    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.

    J L 2 Replies Last reply
    0
    • M meeram395

      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.

      J Offline
      J Offline
      jkirkerx
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • M meeram395

        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.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        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 the display or visibility attributes of the DOM element.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups