Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: javascript reference id inside of a user control?

Thread Tools

Re: javascript reference id inside of a user control?

Craig Deelsnyder
Posts: n/a
check out the Control.ClientID property

Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET

"Russel harvey" <(E-Mail Removed)> wrote in message
news:052501c36b6c$6e133b60$(E-Mail Removed)...
> Hi,
> I've had a problem to reference an 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.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing USER CONTROL which is inside Masterpagethrough Another USER Control inside normal page. Kiran More ASP .Net Web Controls 2 11-14-2006 12:58 PM
ASP.NET 2.0: master pages and web user controls: reference to a non-shared member requires an object reference bminder ASP .Net 0 06-24-2005 12:22 AM
child controls inside a user control inside a datalist Roman ASP .Net Web Controls 2 01-04-2005 07:07 AM
Render an User Control inside a mail body without having any Page reference Henri ASP .Net 0 12-11-2004 03:36 PM
Re: Can We Use EXEC CGI Inside a JavaScript Applet Inside an HTML File? David Dorward HTML 1 06-28-2003 09:30 AM