Solved

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

Posted on 2004-08-11
2
575 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
If your vDisk VHD file gets deleted from the image store accidentally or on purpose, you won't be able to remove the vDisk from the PVS console. There is a known workaround that is solid.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

929 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

20 Experts available now in Live!

Get 1:1 Help Now