System.NullReferenceException

M

Mike Morse

I have a form that uses a code behind done in C#. The forms contains a
textbox and I am hooking into the onbeforechange event to do some code
validation.

To get the correct source node I am running this code.
private IXMLDOMNode normalizeSource(DataDOMEvent e)
{
if(e.Parent.nodeType == DOMNodeType.NODE_ELEMENT && e.Source.nodeType ==
DOMNodeType.NODE_TEXT)
return e.Parent;

if (e.Source.nodeType == DOMNodeType.NODE_ELEMENT || e.Source.nodeType ==
DOMNodeType.NODE_ATTRIBUTE
return e.Source;

return null;
}

After this I perform some very simple validation which does not pertain the
my question. The odd thing that is happening here is that if the user types
directly into the text box my validation code works as needed. However, if
the user has something copied to the clip board and then paste it into the
text box I keep getting a System.NullReferenceException. Yet I cannot find
the source of my problems.

Anyone have any ideas? Thanks,

-mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top