Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-08-11
2
Medium Priority
?
591 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 200 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Are you an Exchange administrator employed with an organization? And, have you encountered a corrupt Exchange database due to which you are not able to open its EDB file. This article will explain all the steps to repair corrupt Exchange database.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

715 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