Solved

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

Posted on 2004-08-11
2
588 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The recent Petya-like ransomware attack served a big blow to hundreds of banks, corporations and government offices The Acronis blog takes a closer look at this damaging worm to see what’s behind it – and offers up tips on how you can safeguard your…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

627 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