javascriptc#asp.netfindcontrol

Find Control in javascript by using variable


i have to Hide/Unhide panel of asp web form by javascript. pls Help

for (var l = 1; l <= ddlSizesValue; l++) 
  {
        var Size = "pnlProduct1Design1Color1Size" + l;
        var pnl = document.getElementById('pnlProduct')
       var pnlSize = document.getElementById(Size);
        pnlSize.style.display = 'block';            
   }

before javascript i was using

System.Web.UI.HtmlControls.HtmlControl pnlSize = (System.Web.UI.HtmlControls.HtmlControl)pnlProduct.FindControl(Size);

in c# to find control and it was working fine. but to avoid page load i am using javascripting.

thanks in advance


Solution

  • i have done it by changing variable size to:

      var Size = "ctl00_ContentPlaceHolder1_ucSetProduct1Detail_pnlProduct1Design1Color1Size" + l;
    

    now its working fine.