JavaScript - microsoft jscript runtime error object required

Asked By uzn on 27-Oct-10 04:18 PM

function printPageZB()
{

document.getElementById('pnlPhotoBook').style.display = 'none';

window.print();

}



I'm getting this error "microsoft jscript runtime error object required". 
please help

Thanks
Rolf Jaeger replied to uzn on 27-Oct-10 05:35 PM
Hi there:

I tested your code with the ASP.NET code listed partially below and didn't get an error...

Hope this helped,
Rolf

<script language="javascript" type="text/javascript">
  function printPageZB() 
  
  alert(document.getElementById('pnlPhotoBook'));
  document.getElementById('pnlPhotoBook').style.display = none; 
  window.print();
  }
</script>
<body>
  <form id="form1" runat="server">
  <div>
    <input type="button" onclick="printPageZB()" />
    <asp:Panel ID="pnlPhotoBook" runat="server"/>
  </div>
  </form>
</body>
U replied to Rolf Jaeger on 27-Oct-10 08:37 PM
Here is my code.
function printPage() {
        if (document.getElementById('pnlPhotoBook').style.display = 'block')
       {
          document.getElementById('pnlPhotoBook').style.display = 'none';
          window.print();
          document.getElementById('pnlPhotoBook').style.display = 'block';
          window.print();
        }
        else

          window.print();

      }

 <input id="Button1" type="button" value="Print Report" onclick = "printPage()"/>

is the syntax correct? I'm not getting desired output.
uzn replied to U on 28-Oct-10 10:05 AM
I'm receiving the same error at the if statement. can anybody help me?
Rolf Jaeger replied to U on 28-Oct-10 11:34 AM
Hi U:

I suspect there's something fishy about the element. Insert the following statement at the beginning of your function (before the if statement):

alert(document.getElementById('pnlPhotoBook'))

and see what you get.

Best wishes,
Rolf
Rolf Jaeger replied to U on 28-Oct-10 11:34 AM
Hi U:

I suspect there's something fishy about the element. Insert the following statement at the beginning of your function (before the if statement):

alert(document.getElementById('pnlPhotoBook'))

and see what you get.

Best wishes,
Rolf
uzn replied to Rolf Jaeger on 28-Oct-10 11:48 AM
Hi Rolf
I modified my script .

function printPage() {

var functionname;

if (document.getElementById('pnlPhotoBook').visible = 'True')

{

document.getElementById('pnlPhotoBook').style.display = 'none';

window.print();

document.getElementById('pnlPhotoBook').style.display = 'block';

window.print();

}

else

window.print();

}

I dont see the error now. it is working fine. But when th panel is not visible , it is thrwoing an error Microsoft JScript runtime error: 'document.getElementById(...)' is null or not an object.
how should i get that working.

Rolf Jaeger replied to uzn on 28-Oct-10 01:00 PM
Hi U:

I have a question and a suggestion. 

My question: what did you have to do to get your code to work?

My suggestion: you could change your first if statement to:

if (document.getElementById('pnlPhotoBook') != null)

Hope this helped,
Rolf


uzn replied to Rolf Jaeger on 28-Oct-10 01:34 PM
Thanks Rolf that worked
microsoft jscript runtime error object required - rajkumar sendhilnathan replied to Rolf Jaeger on 30-May-11 07:01 AM
 

Hi,

  i want to multiple two values in the grid footer. for that i used below script. its correctly works for row entries
when for third entry it showed the below error



for this coding

function sum() {

var a = document.getElementById('<%=((TextBox)gridcategory.FooterRow.FindControl("txtfapprovedweight")).ClientID%>').value;

var b = document.getElementById('<%=((TextBox)gridcategory.FooterRow.FindControl("txtfapprovedunit")).ClientID%>').value;

var c, sum;

sum = a * b;


c = sum;

document.getElementById('<%=((TextBox)gridcategory.FooterRow.FindControl("txtfapprovedvalue")).ClientID%>').value = c;

}




give some idea to recover that

Rolf Jaeger replied to uzn on 01-Jun-11 08:14 PM
If you haven't done so alreeady, check document and make sure you actually have a element with the ID you are looking for. 
sadhana replied to uzn on 12-Aug-11 02:55 AM

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CustomerwiseRefundList.aspx.cs" Inherits="Inventory_Reports_sales_CustomerwiseRefundList" %>

<%@ Register Src="../../../Controls/SearchByLetter.ascx" TagName="SearchByLetter" TagPrefix="uc1" %>

<%@ Register Src="../../../Controls/MyCalendar.ascx" TagName="VDatePicker" TagPrefix="MyCalender" %>

<!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 id="Head1" runat="server">

<title>Densoft Infotech Pvt. Ltd. : CustomerwiseRefund Report</title>

<link type="text/css" rel="Stylesheet" href="../../../css/densoftGrid.css" />

<link type="text/css" rel="Stylesheet" href="../../../Controls/css/SearchByLetter.css" />

<link type="text/css" rel="Stylesheet" href="../../../css/densoft.css" />

<script type="text/javascript" src="../../../javascript/GridHelper.js"> </script>

<script type="text/javascript" src="../../../javascript/Printing.js"></script>

<script type="text/javascript" src="../../../javascript/VScript.js"> </script>

<script type="text/javascript" src="../../../javascript/SMSEmail.js"> </script>

<%--<script type="text/javascript" src="../../javascript/densoft.js"> </script>--%>

<script type="text/javascript" language="javascript" src="../../../Controls/javascript/SearchByLetter.js"></script>

<script type="text/javascript" language="javascript">


function ReturnToParentLetterPage()

{

var myArray = GetSelectedRow('GridView1', '1,4,10');

// alert("Paent ti =" + myArray);

window.returnValue = myArray;

window.close();


}


function PrintLabels()

{

//debugger;

var SelectedId=GetSelectedChecked('GridView1',1);// here 1 is Patient id column index into the grid.


if(SelectedId==null || SelectedId=="") // null means There is no entry in grid.

{

alert("Please select at least one entry from the list.");

return false;

}

var category = "1"; // 1 for patients

// var result=Reports_Patients_PatientGroup.PrintPatientLabel(SelectedId).value;

// if(result!=null)

// {

// GetPrint(result);

// }

var url="../../Masters/Reports/FrmLabel.aspx?catId=" + SelectedId + "&catname=" + category;

var WinSettings = "center:yes;resizable:yes;dialogHeight:300px;dialogWidth:670px;status:no;scroll:no;";

var arg = window.showModalDialog(url , null, WinSettings);

}



function OpenPatientReport()

{

debugger;

alert('hi');

var strText='';

var strValue=document.getElementById("txtOrderNo").value;

var strText=document.getElementById("txtCustomerName").value;

var strctllist=document.getElementById('ctlList_txtSelectedText').value;

var hdCategoryId=document.getElementById("hdCategoryId").value;

var strLocationId=document.getElementById("cmbLocation").value;

var result=Inventory_Reports_sales_CustomerwiseRefundList.GetPatientsReport(strText,strValue,strGroup,strctllist,hdCategoryId,strLocationId).value;

alert(result);

if(result!=null)

{


GetPrint(result);

}

}


function ShowCommonMasters(CategoryId,ComboName)

{

var url="../../Masters/CommonMasters.aspx?catId=" + CategoryId;

var WinSettings = "center:yes;resizable:yes;dialogHeight:450px;dialogWidth:465px;status:no;scroll:auto;";

var arg = window.showModalDialog(url , null, WinSettings);

if(arg !=null && arg !='undefined')

{

FillCommonMasterCombo(arg,ComboName);

//alert(arg);

}

}

function FillCommonMasterCombo(result,dropdown)

{


dropdown=document.getElementById(dropdown);

if(dropdown==null || dropdown=='undefined')

{

return;

}

if(result=="")

{

result= "^--Select--|";

}


dropdown.innerHTML= "";

var rows = result.split('|');

for (var i = 0; i < rows.length - 1; ++i)

{

var values = rows[i].split('^');

var option = document.createElement("OPTION");

option.value = values[0];

option.innerHTML = values[1];

dropdown.appendChild(option);

}

}

</script>

<link href="mvwres:10-MyCalender.VDatePickerCSS.css,MyCalender, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"

rel="Stylesheet" type="text/css" />

</head>

<body>

<form id="form1" runat="server">


<asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="360000">

</asp:ScriptManager>



<table style="width: 100%; background-color: White" align="left">

<tr>

<td>

<table class="MainTable" style="width: 100%;">

<tr>

<td colspan="3"

class="MainTableHeader" style="height: 30px">

<asp:Label ID="lblHeading" runat="server" Text=" CustomerwiseRefund List" Width="302px"></asp:Label></td>

</tr>

<tr>

<td align="left" valign="middle">

<table cellspacing="1" class="searchArea" style="font-size: 12px; width: 100%; font-family: Verdana;">

<tr>

<td align="center" id="tdLocation" runat="server" class="HeadingColor" style="width: 138px; height: 20px;">

Location Name</td>

<td align="center" class="HeadingColor" style="width: 109px; height: 20px">

InvoiceNo</td>

<td class="HeadingColor" style="width: 109px; height: 20px">

InvoiceDate</td>

<td align="center" style="width: 128px; height: 20px;">

RefundDate</td>

<td align="center" style="width: 15%; height: 20px;">

RefundNo</td>

<td align="center" style="width: 100px; height: 20px;">CustomerName

</td>

<td align="center" style="width:15px; height: 20px;">

</td>

<td align="left" style=" width:170px; height: 20px;" colspan="1">

Customer Per Page:</td>

</tr>

<tr>

<td id="tdLocationCombo" align="center" runat="server">

<asp:DropDownList ID="cmbLocation" runat="server" AutoPostBack="True" CssClass="DropDownCss"

Style="left: -67px;" Width="152px">

<asp:ListItem>--Select--</asp:ListItem>

</asp:DropDownList></td>

<td align="center" style="width: 109px">

<asp:TextBox ID="txtOrderNo" runat="server" CssClass="TextBox" Width="77px"></asp:TextBox></td>

<td align="center">

<MyCalender:VDatePicker ID="dpIssueDate" runat="server" />

</td>

<td align="center" style="width: 128px">

<MyCalender:VDatePicker ID="dpFromDate" runat="server" />

</td>

<td align="center">

<asp:TextBox ID="txtRefundNo" runat="server" CssClass="TextBox" Width="77px"></asp:TextBox></td>

<td align="center" style="width: 100px">

<asp:TextBox ID="txtCustomerName" runat="server" CssClass="TextBox" Width="100px"></asp:TextBox></td>



<td align="center" style="width: 15px">

<input id="btnSupplier" class="plusButton" onclick="OpenMasterSearchCustomer();return false;"

type="button" value="+" /></td>

<td align="left" style="width: 150px;">

<asp:DropDownList ID="cmbPagesize" runat="server" CssClass="DropDownCss" Width="150px">

</asp:DropDownList>

</td>

<td>

<input id="Button1" class="plusButton" onclick="ShowCommonMasters('1092','cmbPagesize');"

type="button" value="+" /></td>

<td align="left" style="width: 109px;" colspan="3">

<asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="button" OnClick="btnSearch_Click" /> </td>

</tr>


</table>

</td>

</tr>


<tr>

<td align="left" valign="middle">

<uc1:searchbyletter id="ctlList" runat="server" allowpostback="true" onclick="ctlList_Click" ></uc1:searchbyletter>

</td>

</tr>

<tr>

<td align="left" valign="middle">

<input id="btnPrint" runat="server" class="button" onclick="OpenPatientReport();" style="width: 66px"

type="button" value="Print List" onserverclick="btnPrint_ServerClick" />

<input id="btnLabels" runat="server" class="button" onclick="PrintLabels();" style="width: 77px"

type="button" value="Print Labels" />

<input id="btnEmail" runat="server" class="button" onclick="javascript:OpenSendEmailPageList();" style="width: 62px"

type="button" value="Email" />

<asp:Button ID="btnExcel" runat="server" class="button"

Text="EXCEL" Width="61px" />

<input id="btnOK" runat="server" class="button" onclick="javascript:ReturnToParentLetterPage();"

type="button" value="OK" />

<input runat="server" id="btnClose" onclick="javascript:ClosePageReport();" type="button" value="Close" class="button" />

<%--<input runat="server" id="btnCloseDialog" onclick="javascript:CloseDialog();" type="button" value="Close" class="button" />--%>

<asp:Button ID="btnRefresh" runat="server" Text="Refresh" CssClass="displayNone" /></td>

</tr>

<tr>

<td valign="top" style="width: 100%;">

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">

<ContentTemplate>

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"

BorderWidth="0px" CellSpacing="1" Width="100%" CssClass="Grid" OnRowDataBound="GridView1_RowDataBound"

OnPageIndexChanging="GridView1_PageIndexChanging">

<Columns>


<asp:TemplateField>

<ItemTemplate>

<input id="chkSelect" type="checkbox" runat="server" />

</ItemTemplate>

<ItemStyle HorizontalAlign="Center" Width="10px" />

<HeaderStyle Width="10px" />

</asp:TemplateField>


<asp:BoundField DataField="OrderId" HeaderText="OrderId">

<ItemStyle CssClass="displayNone" />

<HeaderStyle CssClass="displayNone" />

</asp:BoundField>


<asp:BoundField DataField="ParentOrderNo" HeaderText="Invoice No">

<ItemStyle Width="12%" />

<HeaderStyle Width="12%" />

</asp:BoundField>

<asp:BoundField DataField="ParentOrderDate" HeaderText="Invoice Date">

<ItemStyle Width="12%" />

<HeaderStyle Width="12%" />

</asp:BoundField>


<asp:TemplateField HeaderText="Refund No">

<ItemTemplate>

<a id="lnkOrderNo" class="link" runat="server">

<%#Eval("OrderNo")%>

</a>

</ItemTemplate>

<HeaderStyle Width="12%" />

<ItemStyle Width="12%" />

</asp:TemplateField>



<asp:BoundField DataField="OrderDate" HeaderText="Refund Date">

<ItemStyle Width="12%" />

<HeaderStyle Width="12%" />

</asp:BoundField>


<asp:BoundField DataField="SupplierName" HeaderText="Customer Name">

<ItemStyle Width="20%" />

<HeaderStyle Width="20%" />

</asp:BoundField>


<asp:BoundField HeaderText="Remarks" DataField="OrderNote">

<ItemStyle Width="20%" />

<HeaderStyle Width="20%" />

</asp:BoundField>


<asp:BoundField HeaderText="Refund Amt">

<ItemStyle Width="12%" />

<HeaderStyle Width="12%" />

</asp:BoundField>


</Columns>

<RowStyle CssClass="DataCell" />

<EmptyDataRowStyle CssClass="EmptyData" />

<EmptyDataTemplate>

<span class="EmptyData">Data Not Found.</span>

</EmptyDataTemplate>

<SelectedRowStyle CssClass="SelectedRow" />

<HeaderStyle CssClass="HeadingRow" />

<AlternatingRowStyle CssClass="DataCell" />

</asp:GridView>

<div style="text-align: right; width: 100%;">

<asp:Label ID="lblMessage" runat="server" Font-Bold="True" ForeColor="#C00000" Visible="False"></asp:Label>

</div>

<Triggers>

<asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />

<asp:AsyncPostBackTrigger ControlID="btnctlList" EventName="Click" />

<asp:AsyncPostBackTrigger ControlID="btnRefresh" EventName="Click" />

</Triggers>

</ContentTemplate>



</asp:UpdatePanel>

<asp:HiddenField ID="hdCustomerName" runat="server" />

</td>

</tr>

</table>

</td>

</tr>

</table>

</form>

<script type="text/javascript" language="javascript">


function OpenSendEmailPageList()

{

//debugger;

var WinSettings = "center:yes;resizable:yes;dialogHeight:600px;dialogWidth:900px;status:no;scrolling:no;background-color:White"

var selectedRows = GetSelectedChecked('GridView1','1');

if(selectedRows==null || selectedRows=="")

{

alert("Please select at least one entry from the list.");

return false;

}

var url="../../Letters/SendEmail.aspx?patid="+ selectedRows;

var ReturnArray = window.showModalDialog(url, selectedRows, WinSettings);

}


</script>

</body>

</html>