hide drowndownList

Discussion in 'ASP .Net' started by JFB, Nov 1, 2006.

  1. JFB

    JFB Guest

    Hi all,
    This is crazy...
    The name of my dropdownlist on the ascx page is:
    nameOfMyControl_DropDownListName
    Like:
    contactWebUserControl_DropDownList2
    Now I put my ascx in sharepoint and the name is :
    <select
    name="Left:g_708f9018_c320_46a1_bb9c_ebb3b67b8184:_ctl0:DropDownList2"
    id="Left_g_708f9018_c320_46a1_bb9c_ebb3b67b8184__ctl0_DropDownList2"

    I have a fuction in java to catch this name as:
    var drop2 = document.getElementById("contactWebUserControl_DropDownList2");

    How can I do it now??
    Tks

    JFB
    JFB, Nov 1, 2006
    #1
    1. Advertising

  2. you have to link to JavaScript through code behind. This will catch the name
    no matter what it is at run time.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA
    http://gregorybeamer.spaces.live.com

    *************************************************
    Think outside of the box!
    *************************************************
    "JFB" <> wrote in message
    news:OpnbIzf$...
    > Hi all,
    > This is crazy...
    > The name of my dropdownlist on the ascx page is:
    > nameOfMyControl_DropDownListName
    > Like:
    > contactWebUserControl_DropDownList2
    > Now I put my ascx in sharepoint and the name is :
    > <select
    > name="Left:g_708f9018_c320_46a1_bb9c_ebb3b67b8184:_ctl0:DropDownList2"
    > id="Left_g_708f9018_c320_46a1_bb9c_ebb3b67b8184__ctl0_DropDownList2"
    >
    > I have a fuction in java to catch this name as:
    > var drop2 =
    > document.getElementById("contactWebUserControl_DropDownList2");
    >
    > How can I do it now??
    > Tks
    >
    > JFB
    >
    Cowboy \(Gregory A. Beamer\), Nov 1, 2006
    #2
    1. Advertising

  3. JFB

    JFB Guest

    Tks for you reply...
    How can I do that? Sorry but I dpn't get it
    Rgds
    JFB

    "Cowboy (Gregory A. Beamer)" <> wrote in
    message news:erMBwjg$...
    > you have to link to JavaScript through code behind. This will catch the
    > name no matter what it is at run time.
    >
    > --
    > Gregory A. Beamer
    > MVP; MCP: +I, SE, SD, DBA
    > http://gregorybeamer.spaces.live.com
    >
    > *************************************************
    > Think outside of the box!
    > *************************************************
    > "JFB" <> wrote in message
    > news:OpnbIzf$...
    >> Hi all,
    >> This is crazy...
    >> The name of my dropdownlist on the ascx page is:
    >> nameOfMyControl_DropDownListName
    >> Like:
    >> contactWebUserControl_DropDownList2
    >> Now I put my ascx in sharepoint and the name is :
    >> <select
    >> name="Left:g_708f9018_c320_46a1_bb9c_ebb3b67b8184:_ctl0:DropDownList2"
    >> id="Left_g_708f9018_c320_46a1_bb9c_ebb3b67b8184__ctl0_DropDownList2"
    >>
    >> I have a fuction in java to catch this name as:
    >> var drop2 =
    >> document.getElementById("contactWebUserControl_DropDownList2");
    >>
    >> How can I do it now??
    >> Tks
    >>
    >> JFB
    >>

    >
    >
    JFB, Nov 2, 2006
    #3
  4. This javascript function will help you. Call it as

    var drop2 = findControl("select", "contactWebUserControl_DropDownList2");

    function findControl(tagName, controlId)
    {
    var aControls = document.getElementsByTagName(tagName);
    if (aControls==null)
    return null;
    for (var i=0; i< aControls.length; i++)
    {
    var j = aControls.id.lastIndexOf(controlId);
    if ((j > -1) && (j == (aControls.id.length - controlId.length)))
    return aControls;
    }
    return null;
    }


    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]


    "JFB" <> wrote in message
    news:OpnbIzf$...
    > Hi all,
    > This is crazy...
    > The name of my dropdownlist on the ascx page is:
    > nameOfMyControl_DropDownListName
    > Like:
    > contactWebUserControl_DropDownList2
    > Now I put my ascx in sharepoint and the name is :
    > <select
    > name="Left:g_708f9018_c320_46a1_bb9c_ebb3b67b8184:_ctl0:DropDownList2"
    > id="Left_g_708f9018_c320_46a1_bb9c_ebb3b67b8184__ctl0_DropDownList2"
    >
    > I have a fuction in java to catch this name as:
    > var drop2 =
    > document.getElementById("contactWebUserControl_DropDownList2");
    >
    > How can I do it now??
    > Tks
    >
    > JFB
    >
    Eliyahu Goldin, Nov 2, 2006
    #4
  5. JFB

    JFB Guest

    Tks for you reply Eliyahu,
    Looks like it works but I got an error "style" is null or not an object.
    What is this mean? Any ideas?
    Rgds

    JFB


    "Eliyahu Goldin" <> wrote in
    message news:uIrs7jl$...
    > This javascript function will help you. Call it as
    >
    > var drop2 = findControl("select", "contactWebUserControl_DropDownList2");
    >
    > function findControl(tagName, controlId)
    > {
    > var aControls = document.getElementsByTagName(tagName);
    > if (aControls==null)
    > return null;
    > for (var i=0; i< aControls.length; i++)
    > {
    > var j = aControls.id.lastIndexOf(controlId);
    > if ((j > -1) && (j == (aControls.id.length - controlId.length)))
    > return aControls;
    > }
    > return null;
    > }
    >
    >
    > --
    > Eliyahu Goldin,
    > Software Developer & Consultant
    > Microsoft MVP [ASP.NET]
    >
    >
    > "JFB" <> wrote in message
    > news:OpnbIzf$...
    >> Hi all,
    >> This is crazy...
    >> The name of my dropdownlist on the ascx page is:
    >> nameOfMyControl_DropDownListName
    >> Like:
    >> contactWebUserControl_DropDownList2
    >> Now I put my ascx in sharepoint and the name is :
    >> <select
    >> name="Left:g_708f9018_c320_46a1_bb9c_ebb3b67b8184:_ctl0:DropDownList2"
    >> id="Left_g_708f9018_c320_46a1_bb9c_ebb3b67b8184__ctl0_DropDownList2"
    >>
    >> I have a fuction in java to catch this name as:
    >> var drop2 =
    >> document.getElementById("contactWebUserControl_DropDownList2");
    >>
    >> How can I do it now??
    >> Tks
    >>
    >> JFB
    >>

    >
    >
    JFB, Nov 2, 2006
    #5
  6. JFB

    JFB Guest

    Never Mine Eliyahu... I got it...
    I use only _DropDownList2 as name.
    Tks
    JFB


    "Eliyahu Goldin" <> wrote in
    message news:uIrs7jl$...
    > This javascript function will help you. Call it as
    >
    > var drop2 = findControl("select", "contactWebUserControl_DropDownList2");
    >
    > function findControl(tagName, controlId)
    > {
    > var aControls = document.getElementsByTagName(tagName);
    > if (aControls==null)
    > return null;
    > for (var i=0; i< aControls.length; i++)
    > {
    > var j = aControls.id.lastIndexOf(controlId);
    > if ((j > -1) && (j == (aControls.id.length - controlId.length)))
    > return aControls;
    > }
    > return null;
    > }
    >
    >
    > --
    > Eliyahu Goldin,
    > Software Developer & Consultant
    > Microsoft MVP [ASP.NET]
    >
    >
    > "JFB" <> wrote in message
    > news:OpnbIzf$...
    >> Hi all,
    >> This is crazy...
    >> The name of my dropdownlist on the ascx page is:
    >> nameOfMyControl_DropDownListName
    >> Like:
    >> contactWebUserControl_DropDownList2
    >> Now I put my ascx in sharepoint and the name is :
    >> <select
    >> name="Left:g_708f9018_c320_46a1_bb9c_ebb3b67b8184:_ctl0:DropDownList2"
    >> id="Left_g_708f9018_c320_46a1_bb9c_ebb3b67b8184__ctl0_DropDownList2"
    >>
    >> I have a fuction in java to catch this name as:
    >> var drop2 =
    >> document.getElementById("contactWebUserControl_DropDownList2");
    >>
    >> How can I do it now??
    >> Tks
    >>
    >> JFB
    >>

    >
    >
    JFB, Nov 2, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jerad Rose

    Dynamically Show/Hide Groups of TR's

    Jerad Rose, Jun 24, 2003, in forum: ASP .Net
    Replies:
    12
    Views:
    11,605
    intrader
    Jul 10, 2005
  2. Jurij P

    hide password on client side

    Jurij P, Jul 7, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    398
    Wim Hollebrandse
    Jul 7, 2003
  3. J Gao

    How to hide columns in Datagrid

    J Gao, Jul 22, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    5,709
    J Gao
    Jul 22, 2003
  4. jonnylbluejeans
    Replies:
    4
    Views:
    5,880
    Rick Spiewak
    Jul 24, 2003
  5. Bob
    Replies:
    3
    Views:
    324
    David C
    Dec 7, 2007
Loading...

Share This Page