document.getElementById to Find Field in User Control that is Inside an UpdatePanel

Discussion in 'ASP .Net' started by Frank, Jan 10, 2009.

  1. Frank

    Frank Guest

    I have been googling this for quite sometime and have been finding guidance
    and samples that just don't work with my particular scenario.

    I simply need for my JavaScript to be able to get a reference to an HTML
    hidden field, where:
    1. the hidden field exists in a user control that is dynamically added to a
    PlaceHolder (in the code behind)
    2. the PlaceHolder that hosts the user control exists within an AJAX
    UpdatePanel.

    I have received different bits of advice on this - but none apparently
    account for *both* of the above facts.

    I'd really appreciate guidance on how to declare the hidden field in the
    user control (i.e., does it need runat=server?), and then how to obtain it's
    current value in client-side JavaScript - given that the user control is
    ultimately rendered within an UpdatePanel.

    What's complicating things - at least for me - is that (1) the user control
    is renaming the hidden field; and (2) the contents of an update panel are
    apparently built by javascript.

    Thanks
    Frank, Jan 10, 2009
    #1
    1. Advertising

  2. Frank

    bruce barker Guest

    Re: document.getElementById to Find Field in User Control that isInside an UpdatePanel

    its depends on the use of the hidden control. if you need access to it
    from the usercontrol then use a runat="server" and register clientscript
    in the usercontrol to save the name:

    ScriptManager.RegisterStartupScript(
    this,
    this.GetType(),
    "hidden",
    string.Format("var theHiddenFieldName = '{0}';",
    myHiddenField.ClientID),
    true);


    -- bruce (sqlwork.com)

    Frank wrote:
    > I have been googling this for quite sometime and have been finding guidance
    > and samples that just don't work with my particular scenario.
    >
    > I simply need for my JavaScript to be able to get a reference to an HTML
    > hidden field, where:
    > 1. the hidden field exists in a user control that is dynamically added to a
    > PlaceHolder (in the code behind)
    > 2. the PlaceHolder that hosts the user control exists within an AJAX
    > UpdatePanel.
    >
    > I have received different bits of advice on this - but none apparently
    > account for *both* of the above facts.
    >
    > I'd really appreciate guidance on how to declare the hidden field in the
    > user control (i.e., does it need runat=server?), and then how to obtain it's
    > current value in client-side JavaScript - given that the user control is
    > ultimately rendered within an UpdatePanel.
    >
    > What's complicating things - at least for me - is that (1) the user control
    > is renaming the hidden field; and (2) the contents of an update panel are
    > apparently built by javascript.
    >
    > Thanks
    >
    >
    bruce barker, Jan 10, 2009
    #2
    1. Advertising

  3. Frank

    Frank Guest

    I need to access the hidden field from JavaScript (client-side).
    Specifically, the JavaScript needs to find the current value of the hidden
    field that is located within a user control that is in turn located within
    an UpdatePanel.

    How can I do that?




    "bruce barker" <> wrote in message
    news:e2EV$...
    > its depends on the use of the hidden control. if you need access to it
    > from the usercontrol then use a runat="server" and register clientscript
    > in the usercontrol to save the name:
    >
    > ScriptManager.RegisterStartupScript(
    > this,
    > this.GetType(),
    > "hidden",
    > string.Format("var theHiddenFieldName = '{0}';",
    > myHiddenField.ClientID),
    > true);
    >
    >
    > -- bruce (sqlwork.com)
    >
    > Frank wrote:
    >> I have been googling this for quite sometime and have been finding
    >> guidance and samples that just don't work with my particular scenario.
    >>
    >> I simply need for my JavaScript to be able to get a reference to an HTML
    >> hidden field, where:
    >> 1. the hidden field exists in a user control that is dynamically added to
    >> a PlaceHolder (in the code behind)
    >> 2. the PlaceHolder that hosts the user control exists within an AJAX
    >> UpdatePanel.
    >>
    >> I have received different bits of advice on this - but none apparently
    >> account for *both* of the above facts.
    >>
    >> I'd really appreciate guidance on how to declare the hidden field in the
    >> user control (i.e., does it need runat=server?), and then how to obtain
    >> it's current value in client-side JavaScript - given that the user
    >> control is ultimately rendered within an UpdatePanel.
    >>
    >> What's complicating things - at least for me - is that (1) the user
    >> control is renaming the hidden field; and (2) the contents of an update
    >> panel are apparently built by javascript.
    >>
    >> Thanks
    Frank, Jan 10, 2009
    #3
    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. musosdev
    Replies:
    1
    Views:
    581
    musosdev
    Sep 28, 2009
  2. Kiran More
    Replies:
    2
    Views:
    301
    Kiran More
    Nov 14, 2006
  3. wk
    Replies:
    5
    Views:
    157
    Dietmar Meier
    Apr 22, 2005
  4. Martin
    Replies:
    3
    Views:
    132
  5. Replies:
    4
    Views:
    151
    Jonas Raoni
    Nov 21, 2006
Loading...

Share This Page