Object reference not set to an instance of an objecObject reference not set to an instance of an object.

Hey, I am trying to get the value of the checkbox without_prices in the page_Load, i got this error: 

Server Error in '/' Application.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

My code is as follows:

<

HTML dir="rtl">

<HEAD>

<title>subjects</title>

<script language="JavaScript">

 

function

checkAll(checkAllItems)

{

var frm = document.form1;

var actVar = checkAllItems.checked;

for(i=0;i< frm.length;i++)

{

e=frm.elements[i];

if ( e.type=='checkbox' && e.name.indexOf("checkItem") != -1 )

e.checked= actVar;

}

}

function

UnCheck()

{

var frm = document.form1;

for(i=0;i< frm.length;i++)

{

e=frm.elements[i];

if ( e.type=='checkbox' && e.name.indexOf("checkAllItems") != -1 )

{

e.checked=

false ;

break;

}

}

}

</script>

<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">

<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">

<meta content="JavaScript" name="vs_defaultClientScript">

<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">

</HEAD>

<body style="FONT-SIZE: 10pt; FONT-FAMILY: tahoma" MS_POSITIONING="GridLayout">

<form id="form1" name="form1" method="post" runat="server">

<uc1:menu id="Menu1" runat="server"></uc1:menu><br>

<asp:label id="lwarning" runat="server" Visible="False" ForeColor="Red"></asp:label><BR>

<P>إنشاء نشرة إصدارات

<asp:dropdownlist id="lstItems" runat="server" AutoPostBack="True">

<asp:ListItem Value="1">كتب</asp:ListItem>

<asp:ListItem Value="2">موسيقى</asp:ListItem>

<asp:ListItem Value="3">برامج</asp:ListItem>

<asp:ListItem Value="4">أفلام</asp:ListItem>

<asp:ListItem Value="5">لوحات</asp:ListItem>

</asp:dropdownlist>&nbsp;في

<asp:dropdownlist id="lstSubjects" runat="server"></asp:dropdownlist>&nbsp;<asp:button id="bcat" runat="server" Text="إبدأ"></asp:button><br>

</P>

<p>إنشاء نشرة إصدارات<asp:dropdownlist id="lstcreator" runat="server" AutoPostBack="True">

<asp:ListItem Value="1">لمؤلف</asp:ListItem>

<asp:ListItem Value="2">لمغني</asp:ListItem>

<asp:ListItem Value="3">شركة</asp:ListItem>

<asp:ListItem Value="4">لممثل</asp:ListItem>

<asp:ListItem Value="5">لرسام</asp:ListItem>

</asp:dropdownlist>&nbsp;

<asp:textbox id="tcreator" runat="server"></asp:textbox>&nbsp;<asp:button id="bcreator" runat="server" Text="إبدأ"></asp:button><br>

</p>

<p>إنشاء نشرة إصدارات لسلسلة<asp:dropdownlist id="lstseriesitems" runat="server" AutoPostBack="True">

<asp:ListItem Value="1">كتب</asp:ListItem>

<asp:ListItem Value="2">موسيقى</asp:ListItem>

<asp:ListItem Value="4">أفلام</asp:ListItem>

</asp:dropdownlist>&nbsp;

<asp:textbox id="tseries" Runat="server"></asp:textbox>&nbsp;<asp:button id="bseries" runat="server" Text="إبدأ"></asp:button>

<br>

</p>

<br>

<asp:panel id="ltitle" runat="server" Visible="False" Width="100%">

<FONT color="#cc6600"><STRONG>الرجاء إختيار بعض البنود (17 كحد أقصى) عبر النقر على

الزر

&nbsp;&nbsp;أدناه&nbsp;&nbsp;لإنشاء نشرة الإصدارات الخاصة بك</STRONG></FONT></asp:panel>

<br>

<asp:datagrid id="dgItems" runat="server" Visible="False" Width="100%" PagerStyle-NextPageText=">"

PagerStyle-PrevPageText="<" AutoGenerateColumns="false" PageSize="17" AllowPaging="true" BorderWidth="1"

borderColor="#000000" Font-Size="10">

<Columns>

<asp:BoundColumn Visible="False" DataField="id"></asp:BoundColumn>

<asp:BoundColumn Visible="False" DataField="idautosub"></asp:BoundColumn>

<asp:BoundColumn Visible="False" DataField="center"></asp:BoundColumn>

<asp:TemplateColumn>

<HeaderTemplate>

<input type="checkbox" name="checkAllItems" id="checkAllItems" runat="server" onclick="checkAll(this)">

</HeaderTemplate>

<ItemTemplate>

<input type="checkbox" runat="server" id="checkItem" name="checkItem" onclick="UnCheck();"

checked='<%#DetermineChecked(DataBinder.Eval(Container.DataItem, "id"),DataBinder.Eval(Container.DataItem, "center"),DataBinder.Eval(Container.DataItem, "idautosub"))%>'>

</ItemTemplate>

</asp:TemplateColumn>

<asp:TemplateColumn HeaderText="الكل">

<ItemTemplate>

<%

#DetermineImage(DataBinder.Eval(Container.DataItem, "id"),DataBinder.Eval(Container.DataItem, "center"),DataBinder.Eval(Container.DataItem, "itemformat"),DataBinder.Eval(Container.DataItem, "idautosub"))%>

</ItemTemplate>

</asp:TemplateColumn>

<asp:TemplateColumn>

<ItemTemplate>

<br>

<b>

<%

#DataBinder.Eval(Container.DataItem, "title")%>

</b>

<br>

<%

#DetermineDesc(DataBinder.Eval(Container.DataItem, "descp"),DataBinder.Eval(Container.DataItem, "descp1"),DataBinder.Eval(Container.DataItem, "descp2"))%>

<br>

<%

#DeterminePrices(DataBinder.Eval(Container.DataItem, "alldiscount"),DataBinder.Eval(Container.DataItem, "profit"),DataBinder.Eval(Container.DataItem, "price"),DataBinder.Eval(Container.DataItem, "realprice"),DataBinder.Eval(Container.DataItem, "id"))%>

</ItemTemplate>

</asp:TemplateColumn>

</Columns>

<PagerStyle NextPageText="&gt;" PrevPageText="&lt;" HorizontalAlign="Center" Position="TopAndBottom"

Mode="NumericPages"></PagerStyle>

</asp:datagrid>

<p><asp:button id="Bsubmit" runat="server" Visible="False" Text="إبدأ" Width="56px"></asp:button>

<asp:CheckBox ID="without_prices" Text="بدون أسعار" Visible="False" Checked ="False" Runat="server"></asp:CheckBox>

<asp:label id="lvendorcodes" runat="server" Visible="False"></asp:label><asp:label id="lfolder" runat="server" Visible="false"></asp:label><asp:label id="lvalue1" runat="server" Visible="false"></asp:label><asp:label id="lvalue2" runat="server" Visible="false"></asp:label><asp:label id="loption" style="Z-INDEX: 101; LEFT: 232px; POSITION: absolute; TOP: 1480px"

runat="server"></asp:label>

<asp:Label id="lsubscriber" style="Z-INDEX: 102; LEFT: 193px; POSITION: absolute; TOP: 1488px"

runat="server" Visible="False"></asp:Label></p>

<uc1:footer id="Footer1" runat="server"></uc1:footer></form>

</body>

</

HTML>

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

In the page Load i want to get the value of without_prices checked as follows:

Session(

"checked") = without_prices.Checked

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Please can i know why am i getting this error and how can i fix it.

thank you in advance

Hiba

0
Hiba84
12/4/2006 1:55:26 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

0 Replies
1485 Views

Similar Articles

[PageSpeed] 21

Reply:

Web resources about - Object reference not set to an instance of an objecObject reference not set to an instance of an object. - asp.net.presentation-controls

Resources last updated: 1/19/2016 3:24:17 AM