473,396 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

NullReferenceException for HtmlGenericControl Body

Hi Experts,

//BodyID Defined as in other page where method ControlWebPage(HtmlGenericControl BodyID) in OnInit method

protected System.Web.UI.HtmlControls.HtmlGenericControl BodyID;


private static void ControlWebPage(HtmlGenericControl BodyID)
{
//Disable Right Click
//BodyID.Attributes.Add("oncontextmenu", "return false;");

//Disable CTRL+N
--> BodyID.Attributes.Add("onkeydown", "return noCTRL();");
//error at this line NullReferenceException

//Disable Drag and Drop
BodyID.Attributes.Add("ondragstart", "return false");

//Disable Back button on browser
BodyID.Attributes.Add("onLoad", "window.history.forward(1);");
}

I treid that body id given
<body id="bi" runat="server"> in source code
and BodyID assigned in codefile

BodyID=bi;


Please give solution for this

thanking you
swathi
Nov 19 '08 #1
2 3564
r035198x
13,262 8TB
The BodyID used in that method is the one that has been passed to the method as a parameter. Where are you calling that method and which value are you passing for that BodyID?
Nov 19 '08 #2
The BodyID used in that method is the one that has been passed to the method as a parameter. Where are you calling that method and which value are you passing for that BodyID?
method was called in DCA_AddDiagnostic.aspx.cs page
calling Method(which is given in query) is in Common.cs class

I Have Declared BodyID in DCA_AddDiagnostic.aspx.cs page

in source code of DCA_AddDiagnostic.aspx
<body id="bi" runat="server">

in DCA_AddDiagnostic.aspx.cs
if i assign BodyID=bi;

then getting error in IE:
----------------------------------------------------------------------------------------------------------

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.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
MagicAjax.Util.GetPrivateField(Object instance, Type type, String fieldName) +43
MagicAjax.AjaxCallHelper.GetPageHiddenDictionary(P age page, String fieldName) +46
MagicAjax.AjaxCallHelper.HandleClientScriptBlocks( Page page, Boolean reflectToClient) +37
MagicAjax.AjaxCallHelper.Page_PreRender(Object sender, EventArgs e) +292
System.Web.UI.Control.OnPreRender(EventArgs e) +2066956
System.Web.UI.Control.PreRenderRecursiveInternal() +77
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360
--------------------------------------------------------------------------------------------------------
with out showing any fault with code...
Nov 19 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: mike p. | last post by:
I have a docbook xml file, and am using standard docbook 1.61.3 xsl stylesheets to do xhtml transform. Transform works fine when using MSXML. When I try to do the following using asp.net 1.1: ...
1
by: Ghada Ayed via DotNetMonster.com | last post by:
Hello every body, please help me in this problem i have written the following C# code in VS.Net and when i run the window application i have got 'System.NullReferenceException' so please if...
3
by: PatricQ | last post by:
I use VS.NET and yes I'm a beginner in ASP.NET. Here is the problem: in "%webroot%\components" is the folowing vb code file: framework.vb ---------------------------------------- Imports...
0
by: VB Programmer | last post by:
I have 2 webforms. When I print out the page.Controls(1).tostring variable one says "HtmlForm", the other "HtmlGenericControl". How can I change the first one to "HtmlForm"? ?...
2
by: Ben | last post by:
I have several pages written in aspx, but sometime the aspx page return the following error. And it hapeen, the whole web application gives this error, that means all the aspx files get affected....
4
by: qualitynice | last post by:
HELP :-)... I'm creating an embedded activex object in an asp.net page using the HtmlGenericControl class. I'm doing this because when I tried to embed it directly in the aspx page, it stopped...
8
by: Randall Parker | last post by:
I want to generate an HTML tag that will look like: <a href="EquipmentServiceCreate.aspx?serial=X01">Create New Service For X01</a> or on a different instance where the user would be viewing...
2
by: Rik Brooks | last post by:
I have a web page that has a placeholder on it called PlaceHolderText. I read some html out of the database. The value for my test is: this is <strong>a test </strongof the html stuff I read...
0
by: papillonhn | last post by:
Please help me. In my HtmlGenericControl object has: an image and a string. Is there anyway to determine or calculate the width of HtmlGenericControl. I need to display this HtmlGenericControl...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.