Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JavaScript Object required error

Status
Not open for further replies.

Padmajak

Programmer
Jun 7, 2008
10
<%@ Page Language="C#" EnableEventValidation="false" MasterPageFile="~/MasterPage2.master" AutoEventWireup="true" CodeFile="personal.aspx.cs" Inherits="vhost.personal" Title="SharedHostingPersonal" %>
<%--<asp:Content ID="Content1" ContentPlaceHolderID="topRight" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="login" Runat="Server">
</asp:Content>--%>

<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script language="javascript" type="text/javascript">
function ShowHide(id)
{
var imgelement = document.getElementById('" + id.ClientId + "');
var imgsrc;
if (imgelement.src.indexOf("plus") >0)
{
imgsrc = imgelement.src;
imgsrc = imgsrc.substring(0,imgelement.src.indexOf("plus")) + "minus.gif";
imgelement.src = imgsrc;
var tr = imgelement.parentnode.parentNode;

var next_tr = tr.nextSiling;
var td = imgelement.parentnode;
var tbody = tr.parentNode;
var trl = tbody.childNodes[1];
var detailnode;
for (var j=0; j>td.childNodes.length; j++)
{
if(td.childNodes[j].nodetype == 1)
{
if(td.childNodes[j].nodeName.toLowerCase() == 'div')
{
detailnode = td.childNodes[j].cloneNode(true);
detailnode.setAttribute('style','');
}
}
}
var newtr = document.createElement('tr');
var newtd = document.createElement('td');
var newfirsttd = newtd.clodeode(true);
newfirsttd.innerHTML = '&nbsp';
newfirsttd.setAttribute('bgcolor', '#ff0000');
newtr.appendChild(newfirsttd);
newtd.colSpan = 8;
newtd.innerHTML = detailnode.innerTML;
newtr.appendChild(newtd);

tbody.insertBefore(newtr.next_tr);

div1 = tbody.parentNode.parentNode.parentNode;
div1.srolltop = 1;

var rodid = tr.id;
var rownumber = rowid.substring(3);
varirowNumber = parseInt(rownumber);

var newscroll = iRowNumber * 14;

div1.crollTop = newscroll;
}
else
{
imgsrc = imgelement.src;
imgsrc = imgsrc.substring(0,imgelement.src.indexOf("minus")) + "html/images/minus.gif";
imgelement.src = imgsrc;
var row = imglement.parentNode.parentNode;

var rowsibling = row.nextsibling;

var rowparent = row.parentNode;
rowparent.removeChild(rowsibling);
}
}


</script>

<P><FONT size="4">&nbsp; Welcome to Shared Hosting Plans</FONT></P>
<p>
&nbsp; &nbsp;&nbsp;
</p>
<p>
<asp:panel ID="Panel" runat="server" Width="720">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound" DataSourceID="SqlDataSource1"
Height="112px" ToolTip="SharedPlans" Width="700px" HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" >
<Columns>

<asp:TemplateField>
<ItemTemplate>
<img src="html/images/plus.gif" id="imgID" runat="server" onclick="ShowHide(this);" />
<div style="display:none">

<table visible=false>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "description") %>'></asp:Label>

</td>

</tr>
</table> </div>

</ItemTemplate></asp:TemplateField>



<asp:BoundField DataField="type" HeaderText="Plan Type" SortExpression="type">
<ItemStyle HorizontalAlign="Center" /><HeaderStyle HorizontalAlign="Center" />
</asp:BoundField>

<asp:BoundField DataField="storage" HeaderText="Disk Storage" SortExpression="storage" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="transfer" HeaderText="Transfer" SortExpression="transfer" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="ODBC" HeaderText="ODBC" SortExpression="ODBC" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="price" HeaderText="Price" DataFormatString="{0:c}" SortExpression="price" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:HyperLinkField HeaderText="Sign up" Text="Purchase" >
<ItemStyle HorizontalAlign="Center" />
</asp:HyperLinkField>

</Columns>
</asp:GridView>
</asp:panel>
<asp:HiddenField ID ="hdnPurchase" runat ="server" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:rjsNetworkscomConnectionString %>"
SelectCommand="SELECT [planid] , [description], [type], [price], [storage], [transfer], [ODBC] , [links] FROM [SharedHostingPlans]">

</asp:SqlDataSource>
</p>
<p>
* Don't see a package to fit your needs? We'll design a custom package for
you. <a href=" here</a> to tell us more about what you need for your company.</p>
<p>
<font size="4"></font>&nbsp;</p>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<%--
<asp:Label ID="lblPrice" runat="server" Font-Bold="True" Font-Size="Medium">$14.95/month</asp:Label>
<asp:HyperLink ID="hdPurchaseNow" runat="server" NavigateUrl="purchase1.aspx">Purchase Now</asp:HyperLink><br />
--%> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;

<br />
<br />
<br /><br /><br /><br />

<%--<script language ="javascript" type ="text/javascript" src ="JScript.js">Onclick();</script>
--%></asp:Content>
 
[0] A rough scanned through the script, you have to understand js objects, attributes and methods are case sensitive. I can suppose you know. Hence, I would say you have to make due diligent before posting... because I find typos after typos. Besides that there are more generic errors.

[1] The imgelemnt, as the major operation in referencing, so that all the rest can perform, is erronous.
>var imgelement = document.getElementById('" + id.ClientId + "');
No only syntactically wrong as string operation, the proper understand of the method is that you pass a string of id's value to it, period. No need to further quote it.
[tt]var imgelement = document.getElementById([red]id.ClientId[/red]);[/tt]

[2] Thereafter, typos after typos and case-in-sensitivity. A selection of them are...
>var tr = imgelement.parentnode.parentNode;
[tt]var tr = imgelement.parent[red]N[/red]ode.parentNode;[/tt]
>var next_tr = tr.nextSiling;
[tt]var next_tr = tr.nextSi[red]b[/red]ling;[/tt]
>var td = imgelement.parentnode;
[tt]var td = imgelement.parent[red]N[/red]ode;[/tt]
>if(td.childNodes[j].nodetype == 1)
[tt]if(td.childNodes[j].node[red]T[/red]ype == 1)[/tt]
>var newfirsttd = newtd.clodeode(true);
[tt]var newfirsttd = newtd.clo[red]neN[/red]ode(true);[/tt]
>newfirsttd.innerHTML = '&nbsp';
[tt]newfirsttd.innerHTML = '&nbsp[red];[/red]';[/tt]
>newtd.innerHTML = detailnode.innerTML;
[tt]newtd.innerHTML = detailnode.inner[red]H[/red]TML;[/tt]
>tbody.insertBefore(newtr.next_tr);
[tt]tbody.insertBefore(newtr[red],[/red]next_tr);[/tt]
>div1.srolltop = 1;
[tt]div1.sroll[red]T[/red]op = 1;[/tt]
>div1.crollTop = newscroll;
[tt]div1.[red]s[/red]crollTop = newscroll;[/tt]
>var rowsibling = row.nextsibling;
[tt]var rowsibling = row.next[red]S[/red]ibling;[/tt]

Does it look good? Not even yet to look into functional validity...
 
Sorry about that. I changed the code. It is giving the error innerHTML contains a null value.
The row is expanding in the gridview but text that come from the "description" is not showing


<%@ Page Language="C#" EnableEventValidation="false" MasterPageFile="~/MasterPage2.master" AutoEventWireup="true" CodeFile="personal.aspx.cs" Inherits="xxxx.personal" Title="SharedHostingPersonal" %>


<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script language="javascript" type="text/javascript">
function ShowHide(id)
{
var imgelement = document.getElementById(id);
var imgsrc;
if (imgelement.src.indexOf("html/images/ig_treePlus") > 0)
{
imgsrc = imgelement.src;
imgsrc = imgsrc.substring(0,imgelement.src.indexOf("html/images/ig_treePlus")) + "html/images/ig_treeMinus.gif";
imgelement.src = imgsrc;
var tr = imgelement.parentNode.parentNode;

var next_tr = tr.nextSibling;
var td = imgelement.parentNode;
var tbody = tr.parentNode;
var trl = tbody.childNodes[1];
var detailnode;
for (var j=0; j>td.childNodes.length; j++)
{
if(td.childNodes[j].nodeType == 1)
{
if(td.childNodes[j].nodeName.toLowerCase() == 'div')
{
detailnode = td.childNodes[j].cloneNode(true);
detailnode.setAttribute('style','');
}
}
}
var newtr = document.createElement('tr');
var newtd = document.createElement('td');
var newfirsttd = newtd.cloneNode(true);
newfirsttd.innerHTML = '&nbsp';
newfirsttd.setAttribute('bgcolor', '#ff0000');
newtr.appendChild(newfirsttd);
newtd.colSpan = 8;
newtd.innerHTML = detailnode.innerHTML;
newtr.appendChild(newtd);

tbody.insertBefore(newtr,next_tr);

div1 = tbody.parentNode.parentNode.parentNode;
div1.scrollTop = 1;

var rowid = tr.id;
var rownumber = rowid.substring(3);
var irowNumber = parseInt(rownumber);

var newscroll = irowNumber * 14;

div1.scrollTop = newscroll;
}
else
{
imgsrc = imgelement.src;
imgsrc = imgsrc.substring(0,imgelement.src.indexOf("ig_treeMinus")) + "ig_treePlus.gif";
imgelement.src = imgsrc;
var row = imgelement.parentNode.parentNode;

var rowsibling = row.nextSibling;

var rowparent = row.parentNode;
rowparent.removeChild(rowsibling);
}
}


</script>
<div>
<P><FONT size="4">&nbsp; Welcome to Shared Hosting Plans</FONT></P>
<p>
&nbsp; &nbsp;&nbsp;
</p>
<p>
<asp:panel ID="Panel" runat="server" Width="720">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound" DataSourceID="SqlDataSource1"
Height="112px" ToolTip="SharedPlans" Width="700px" HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">

<Columns>
<asp:TemplateField>
<ItemTemplate>
<img src="html/images/ig_treePlus.gif" id="imgID" runat="server" onclick="ShowHide(id);" />

<div style="display:none" >

<asp:table runat="server" Width="400">
<asp:TableRow ID="TabelRow1" runat="server" Width="300px">
<asp:TableCell ID="TabelCell1" runat="server">
<asp:Label ID="Label1" runat="server" Text='<%# Eval("description") %>'></asp:Label>

</asp:TableCell>

</asp:TableRow>
</asp:table>
</div>

</ItemTemplate></asp:TemplateField>



<asp:BoundField DataField="type" HeaderText="Plan Type" SortExpression="type">
<ItemStyle HorizontalAlign="Center" /><HeaderStyle HorizontalAlign="Center" />
</asp:BoundField>

<asp:BoundField DataField="storage" HeaderText="Disk Storage" SortExpression="storage" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="transfer" HeaderText="Transfer" SortExpression="transfer" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="ODBC" HeaderText="ODBC" SortExpression="ODBC" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="price" HeaderText="Price" DataFormatString="{0:c}" SortExpression="price" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:HyperLinkField HeaderText="Sign up" Text="Purchase" >
<ItemStyle HorizontalAlign="Center" />
</asp:HyperLinkField>

</Columns>
</asp:GridView>
</asp:panel>
<asp:HiddenField ID ="hdnPurchase" runat ="server" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:rjsNetworkscomConnectionString %>"
SelectCommand="SELECT [planid] , [description], [type], [price], [storage], [transfer], [ODBC] , [links] FROM [SharedHostingPlans]">

</asp:SqlDataSource>
</p>

<font size="4"></font>&nbsp;</p>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<%--
<asp:Label ID="lblPrice" runat="server" Font-Bold="True" Font-Size="Medium">$14.95/month</asp:Label>
<asp:HyperLink ID="hdPurchaseNow" runat="server" NavigateUrl="purchase1.aspx">Purchase Now</asp:HyperLink><br />
--%> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;

<br />
<br />
<br /><br /><br /><br /></div>

--%></asp:Content>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top