• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 806
  • Last Modified:

Script Error while Invoking JavaScript



Hi

I am using a Date Picker in  my aspx page which is invoked by using a Java Script.

The Problem is for the first one or two times I am clicking the Control I am getting the error as

1. Object does not support this property or method.
2. Style is undefined.

Then for the next concecutive time I am clicking the date picker, it works fine.
Also this problem does not occur for all the users, it occurs only for  few members.

What should be the problem...!

PLzz suggest me to resolve this problem.

I here with attach the Code which i am using for reference. I also can provide further more reference if required.

*****************************************CODE*****************************************
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Mydata.aspx.vb" Inherits="ASP.NET_Learn.Mydata"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
      <HEAD>
            <title>Mydata</title>
            <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
            <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
            <meta name="vs_defaultClientScript" content="JavaScript">
            <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
      </HEAD>
      <body MS_POSITIONING="GridLayout">
            <form id="r1f3" method="post" runat="server">
                  <!-- Code Placed For The New Date Control by shiva -->
                  <iframe width="168" height="190" id="gToday:normal:agenda.js" name="gToday:normal:agenda.js" src="ipopeng.htm" scrolling="no" frameborder="0" style="BORDER-RIGHT:2px ridge; BORDER-TOP:2px ridge; Z-INDEX:999; LEFT:-500px; VISIBILITY:visible; BORDER-LEFT:2px ridge; BORDER-BOTTOM:2px ridge; POSITION:absolute; TOP:0px">
                  </iframe>
                  <!-- Code Placed For The New Date Control by shiva -->
                  <% if intdate = 1 then%>
                  <td class="DisplayName" width="59%" align="right" colspan="5" height="10">
                        <p align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start Date :<input id="fromdate" type="text" size="1" name="fromdate" runat="server" Readonly class="Fieldstyle" style="WIDTH:60px">
                              <a href="javascript:style.cursor='hand';" onclick="gfPop.fPopCalendar(r1f3.fromdate);return false;">
                                    <img title="Pick a date" src="images/calendar.gif" border="0" width="15" height="15" runat="server" id="imgdate1" name="imgdate1"></a>
                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End Date :<input id="enddate" type="text" size="1" name="enddate" Readonly runat="server" class="Fieldstyle" style="WIDTH:60px">
                              <a href="javascript:style.cursor='hand';" onclick="gfPop.fPopCalendar(r1f3.enddate);return false;">
                                    <img title="Pick a date" src="images/calendar.gif" border="0" width="15" height="15" runat="server" id="imgdate2" name="imgdate2"></a>
                              &nbsp;&nbsp;&nbsp;&nbsp;
                              <%end if%>
            </form>
            </P>
      </body>
</HTML>

******************************************************************************************

************************************Code in the Code Behind *************************************
Public Class Mydata
    Inherits System.Web.UI.Page
    Protected WithEvents fromdate As System.Web.UI.HtmlControls.HtmlInputText
    Protected WithEvents imgdate1 As System.Web.UI.HtmlControls.HtmlImage
    Protected WithEvents enddate As System.Web.UI.HtmlControls.HtmlInputText
    Protected WithEvents imgdate2 As System.Web.UI.HtmlControls.HtmlImage
    Public intdate As Integer

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region



    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here

    End Sub

    Private Sub Page_prerender(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
        'Put user code to initialize the page here
        intdate = 1

    End Sub

End Class


***************************************************************************************

Thanks in advance.
0
dnlakhani
Asked:
dnlakhani
  • 4
  • 3
1 Solution
 
b1xml2Commented:
There's a simple explanation for this:
1. The IFRAME is a separate container. It will take some time to load, so before everything is loaded, if you click on the links, the error will occur. The faster the client, the faster the IFRAME loads, particularly if as I suspect it is using javascript to create the date picker.
2. What you need is another layer of code on the main page:

<script language="javascript">

function clickIt(value)
{
  if (value != null && gfPop != null &&  gfPop.fPopCalendar == null)
  {
    gfPop.fPopCalendar(value);
  }
 return false;
}

</script>

 <a href="javascript:style.cursor='hand';" onclick="return clickIt(! r1f3 ||  ! r1f3.fromdate ? null : r1f3.fromdate );">
  <img title="Pick a date" src="images/calendar.gif" border="0" width="15" height="15" runat="server" id="imgdate1" name="imgdate1"></a>
0
 
dnlakhaniAuthor Commented:
Thanks for the suggesstion.

The below function which you have mentioned does not help in calling the particualar frame,i think it is not coming in the if loop. Can you please suggest  if any corrections need to be made.

function clickIt(value)
{
  if (value != null && gfPop != null &&  gfPop.fPopCalendar == null)
  {
    gfPop.fPopCalendar(value);
  }
 return false;
}

thanks
 
0
 
b1xml2Commented:
onclick="return clickIt(r1f3 == null ||  r1f3.fromdate  == null ? null : r1f3.fromdate );" <---- if the item is null, a null will be send

next, a change in the logic

unction clickIt(value)
{
  if (value != null && gfPop != null &&  gfPop.fPopCalendar != null)
  {
    gfPop.fPopCalendar(value);
  }
 return false;
}
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
dnlakhaniAuthor Commented:

Still I am getting the same kind of problem.

Here with I am enclosing the Link from where you check the problem directly

http://www.armaninfotech.com/st/mydata.aspx
0
 
b1xml2Commented:
try this:

if (value != null &&  typeof(gfPop) != undefined  &&  typeof(gfPop.fPopCalendar) != undefined)
{
    gfPop.fPopCalendar(value);
}
0
 
b1xml2Commented:
if (value != null &&  typeof(gfPop) != "undefined"  &&  typeof(gfPop.fPopCalendar) != "undefined")
{
    gfPop.fPopCalendar(value);
}

onclick="return clickIt(typeof(r1f3) == "undefined" ||  typeof(r1f3.fromdate)  == "undefined" ? null : r1f3.fromdate );" <---- if the item is null, a null will be send
0
 
dnlakhaniAuthor Commented:

Thanx
got it solved , I made a little syntax change in the solution and got it working.
The undefined should be given in single Quotes.
Thanx
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now