Re: javascript reference id inside of a user control?

Discussion in 'ASP .Net' started by Craig Deelsnyder, Aug 26, 2003.

  1. check out the Control.ClientID property

    --
    Craig Deelsnyder
    Microsoft MVP - ASP/ASP.NET


    "Russel harvey" <> wrote in message
    news:052501c36b6c$6e133b60$...
    > Hi,
    >
    > I've had a problem to reference an asp.net textbox type's
    > id name in a user control (server control), from the
    > client side javascript
    >
    > The javascript: function OpenCalendar(idname, postBack)
    >
    > the idname is used in an ".ascx" file:
    >
    > <asp:textbox id="EndDt" runat="server"
    > utoPostBack="True"></asp:textbox>
    > <A href="javascript:OpenCalendar('EndDt', true)"><IMG
    > src="images/icon-calendar.gif" border="0"></A>
    >
    > however, in the actual html page source, it turn out to
    > be:
    > <input name="_ctl1:EndDt" type="text"
    > onchange="__doPostBack('_ctl1$EndDt','')"
    > language="javascript" id="_ctl1_EndDt" />
    > <A href="javascript:OpenCalendar('EndDt', true)"><IMG
    > src="images/icon-calendar.gif" border="0"></A>
    >
    > and the javascript function breaks, complaint cannot find
    > the "idname" object. Guess it becomes "_ctl1:EndDt"
    > instead of "EndDt", then I tried to use "_ctl1:EndDt",
    > doesn't either.
    >
    > The function works fine in a straight html page, just
    > when the "idname" embedded in an ascx user control, it
    > has problem to reference it.
    >
    > Any help is appreciated.
     
    Craig Deelsnyder, Aug 26, 2003
    #1
    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. vatech1993
    Replies:
    4
    Views:
    5,691
    =?Utf-8?B?U8Opcmdpbw==?=
    Dec 11, 2004
  2. Henri
    Replies:
    0
    Views:
    358
    Henri
    Dec 11, 2004
  3. Leeor Chernov
    Replies:
    2
    Views:
    793
    Leeor Chernov
    Oct 16, 2005
  4. Roman
    Replies:
    2
    Views:
    264
    Roman
    Jan 4, 2005
  5. Kiran More
    Replies:
    2
    Views:
    319
    Kiran More
    Nov 14, 2006
Loading...

Share This Page