Solved

How to call a javascript function from asp.net user control

Posted on 2004-08-11
2
574 Views
Last Modified: 2010-04-01
Hi, I have built an asp.net user control and in it is a textbox named demo1 and an image.  When click on the image, a pop up .js function will appear and the textbox name is passed to the function.  The function does some operations and pass back value to that text box.

However, when i run my program that calls the user control and click on the image, i get a javascript error message -> object required and the error lies in the textbox name that cannot be passed to the function.  What may be the problem?

My codes:
rpt.aspx
_______
<%@ Register TagPrefix="uc" TagName="calendar" src="uc_calendar.ascx" %>
<html><head></head>
<table>
<tr><td><uc:calendar id="caltest1" runat="server"></uc:calendar></td></tr>
</table>
</html>

uc_calendar.ascx
______________
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="uc_calendar.ascx.vb" Inherits="Homepage.uc_calendar" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<LINK href="ens_style.css" type="text/css" rel="stylesheet">
<script language="javascript" src="datetimepicker.js" type="text/javascript"></script>
<SPAN class="clsDatePicker" id="span5a" style="WIDTH: 120px"><INPUT id="chk4" type="checkbox">
      <SPAN id="span5b" style="WIDTH: 65px"></SPAN>&nbsp;&nbsp;
      <asp:textbox id="demo2" runat="server" BorderStyle="None" Width="64px" Height="18px"></asp:textbox>
      <a href="javascript:setCoords(this); NewCal('this.demo2','ddmmyyyy', false, false)">
            <IMG class="clsClickable" id="img3" src="..\Homepage\Graphic\btncd.gif" align="absMiddle" border="0"></a>
</SPAN>

if i remove the textbox from the uc_calendar.ascx and put it in the webform rpt.aspx, then there is no error.  But i want the entire code to be embedded in the user control.  How do i do this?

Pls help.

Tks!



0
Comment
Question by:angelinemb
2 Comments
 
LVL 9

Accepted Solution

by:
nimaig earned 50 total points
ID: 11780378
Can you please paste the generated HTML code (use 'view source' of browser) for the page.
0
 

Author Comment

by:angelinemb
ID: 11780396
Thanks for your comment.  I looked into my HTML code and found the problem.  now i pass it using

<a href="javascript:setCoords(this); NewCal('usercontrol:demo2','ddmmyyyy', false, false)">


and it works!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A procedure for exporting installed hotfix details of remote computers using powershell
In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now