Link to home
Start Free TrialLog in
Avatar of prothera
prothera

asked on

Object Required error using Javascript in Content Page

I am having this problem with 2 different links. The <asp:HyperLink> and <a href>. I need to call 2 different javascript functions in the 'NavigateUrl' in the Hyperlink button and the 'onclick' in <a href>.

In IE, I am getting "Object Required" when I click on either of these links. Here is the code snipet for the HyperLink.

'----------------------------- code from content page ---------------------

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="CatalogRequest.aspx.vb"
  Inherits="forms_CatalogRequest" title="Catalog Request" %>
<%@ MasterType VirtualPath="~/MasterPage.master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

  <script type="text/javascript">
   
    function showHonorifics() {
      //setPostback();
     
      myWindow = window.open("/forms/honorifics.htm","popup","resizable=yes,width=300,height=500");
      myWindow.moveTo(300,300);
    }
  </script>

          <asp:FormView ID="FormViewShipToInfo" DataSourceID="SqlDataSourceAddress"
            DataKeyNames="AddressID" EmptyDataText="no shipping information"
            runat="server" CssClass="body_text" GridLines="None" CellSpacing="0" Visible="true">
            <ItemTemplate>
               <!-- blah blah -->
            </ItemTemplate>
           
            <InsertItemTemplate>
              <asp:Panel ID="Panel4" runat="server" DefaultButton="lnkbtnShipInsUpdate">
              <table border="0" class="table_menu_indent">
                <tr><td><span class="menu_headings">Add Shipping Address</span></td></tr>

                <tr>
                  <td colspan="2">
                    <asp:Label ID="lblInsertShipHonorific" runat="server" Text="Medical Designation/Title:<br />"></asp:Label>
                    <asp:TextBox ID='txtInsertShipHonorific' Text='<%# Bind("Honorific") %>' runat='server' OnChange="javascript:setDirty();"></asp:TextBox>
                   
                    <asp:Label ID="lblInsertShipHonorific2" runat="server" Text=" *"></asp:Label>
                   
                    <asp:HyperLink ID="hlinkInsertShipHonorific"
                      runat="server" Font-Underline="True" NavigateUrl="javascript:setPostback();showHonorifics();" >Approved Designations</asp:HyperLink>

                     
                    <asp:RequiredFieldValidator ID="rfvInsertShipHonorific" runat="server" ErrorMessage="Medical Designation/Title" Display="Dynamic"
                      ControlToValidate="txtInsertShipHonorific" ValidationGroup="grpInsertLogin">Please enter your medical designation/title.</asp:RequiredFieldValidator>
                  </td>
                </tr>

              <br /><br />
              <asp:Button ID="lnkBtnShipInsCancel" Text="Cancel" CommandName="Cancel" runat="server"
                OnClientClick="javascript:warn_pageunload=true;" ></asp:Button>
              &nbsp;&nbsp;
              <asp:Button ID="lnkbtnShipInsUpdate" Text="Add Address" CommandName="Insert" runat="server"
                ValidationGroup="grpInsertLogin" OnClientClick="javascript:warn_pageunload=true;resetFlags;" ></asp:Button>
              </asp:Panel>          
            </InsertItemTemplate>
          </asp:FormView>

'----------------------------------------------------- Master Page -------------------
<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="_newPg_MasterPage" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>title</title>
  <link href="/styles/ie_prothera.css" rel="stylesheet" type="text/css" runat="server" />
 
  <!-- ---------------------------------------------------------------------------------------- -->
  <script type="text/javascript">
   function setPostBack() {
      post_back = "1";     //true;
    }

  </script>

</head>
....
ASKER CERTIFIED SOLUTION
Avatar of Easwaran Paramasivam
Easwaran Paramasivam
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of prothera
prothera

ASKER

ShowHonorifics exists in the Content Page. The other function, setPostBack, exists in the Master Page (if that's what you're asking). I used NavigateURL because I saw it in another's code snipet.

I will give that a try though and let you know. Thanks for the response.
Sorry EastwarenP. My computer was down for a couple of days and I got pulled onto another project. I will look at this tomorrow and get back to you.
I ended up doing it this way. Used an <a href onClick instead of a link button. But I think very similar. Thanks for the help.

<a href="Javascript:;" onclick="setPostBack();window.open('honorifics.htm','honorifics','scrollbars=yes,resizable=yes,width=300,height=390');"> Approved Designations</a>