473,804 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.rtf->clipboard->FreeTextBox

Hi.
I want to get rtf to my FreeTextBox(ftb instance in code below). So I copy
..rtf to clipboard, and now I want to paste it from clipboard to ftb. But I
got error 'Object reference not set to an instance of an object.'
Here's my code:
--
System.Windows. Forms.RichTextB ox MyRTF = new
System.Windows. Forms.RichTextB ox();
MyRTF.LoadFile( "e:\\projects\\ iso\\hmm\\h.rtf ");

MyRTF.SelectAll ();

MyRTF.Copy();

System.Windows. Forms.IDataObje ct data =
System.Windows. Forms.Clipboard .GetDataObject( );

if (data.GetDataPr esent(System.Wi ndows.Forms.Dat aFormats.Rtf))

{

ftb.Text = data.GetData(Sy stem.Windows.Fo rms.DataFormats .Rtf).ToString( );

}

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

Here is error:

--

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.NullRefe renceException: Object reference not set
to an instance of an object.

Source Error:

Line 67: ftb.ToolbarLayo ut = "Paste";
Line 68: System.Windows. Forms.IDataObje ct data =
System.Windows. Forms.Clipboard .GetDataObject( );
Line 69: if (data.GetDataPr esent(System.Wi ndows.Forms.Dat aFormats.Rtf))
Line 70: {
Line 71: ftb.Text =
data.GetData(Sy stem.Windows.Fo rms.DataFormats .Rtf).ToString( );
=============== ===============

Thanks for help.
Nov 18 '05 #1
3 3391
Hi Peter,

I am feeling pretty confident this is caused by the ASPNET user account not
having enough access priviledges to access the windows clipboard. (Also I
wouldn't recommend using System.Windows. Forms namespace in web applications)
The reason I believe this, it that the part of your code that chokes is the
'data' variable - it isn't instantiated (most likely it results in NULL).

--
Regards,
Thomas Johansen (aka. Aylar)
Markusek Peter <markyp.AT.cent rum.sk> wrote:
Hi.
I want to get rtf to my FreeTextBox(ftb instance in code below). So I
copy .rtf to clipboard, and now I want to paste it from clipboard to
ftb. But I got error 'Object reference not set to an instance of an
object.'
Here's my code:
--
System.Windows. Forms.RichTextB ox MyRTF = new
System.Windows. Forms.RichTextB ox();
MyRTF.LoadFile( "e:\\projects\\ iso\\hmm\\h.rtf ");

MyRTF.SelectAll ();

MyRTF.Copy();

System.Windows. Forms.IDataObje ct data =
System.Windows. Forms.Clipboard .GetDataObject( );

if (data.GetDataPr esent(System.Wi ndows.Forms.Dat aFormats.Rtf))

{

ftb.Text =
data.GetData(Sy stem.Windows.Fo rms.DataFormats .Rtf).ToString( );

}

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

Here is error:

Nov 18 '05 #2
What does this question have to do with ASP.Net? Every reference in it is to
Windows Forms.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Markusek Peter" <markyp.AT.cent rum.sk> wrote in message
news:uX******** *****@TK2MSFTNG P11.phx.gbl...
Hi.
I want to get rtf to my FreeTextBox(ftb instance in code below). So I copy
.rtf to clipboard, and now I want to paste it from clipboard to ftb. But I
got error 'Object reference not set to an instance of an object.'
Here's my code:
--
System.Windows. Forms.RichTextB ox MyRTF = new
System.Windows. Forms.RichTextB ox();
MyRTF.LoadFile( "e:\\projects\\ iso\\hmm\\h.rtf ");

MyRTF.SelectAll ();

MyRTF.Copy();

System.Windows. Forms.IDataObje ct data =
System.Windows. Forms.Clipboard .GetDataObject( );

if (data.GetDataPr esent(System.Wi ndows.Forms.Dat aFormats.Rtf))

{

ftb.Text = data.GetData(Sy stem.Windows.Fo rms.DataFormats .Rtf).ToString( );

}

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

Here is error:

--

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.NullRefe renceException: Object reference not set
to an instance of an object.

Source Error:

Line 67: ftb.ToolbarLayo ut = "Paste";
Line 68: System.Windows. Forms.IDataObje ct data =
System.Windows. Forms.Clipboard .GetDataObject( );
Line 69: if (data.GetDataPr esent(System.Wi ndows.Forms.Dat aFormats.Rtf))
Line 70: {
Line 71: ftb.Text =
data.GetData(Sy stem.Windows.Fo rms.DataFormats .Rtf).ToString( );
=============== ===============

Thanks for help.

Nov 18 '05 #3
Hint: "FreeTextBo x" - although I have to admit I was thrown off at first
myself, but I understand what he is trying to accomplish and replied to
him...

--
Regards,
Thomas Johansen (aka. Aylar)

Kevin Spencer <ke***@takempis .com> wrote:
What does this question have to do with ASP.Net? Every reference in
it is to Windows Forms.
"Markusek Peter" <markyp.AT.cent rum.sk> wrote in message
news:uX******** *****@TK2MSFTNG P11.phx.gbl...
Hi.
I want to get rtf to my FreeTextBox(ftb instance in code below). So
I copy .rtf to clipboard, and now I want to paste it from clipboard
to ftb. But I got error 'Object reference not set to an instance of
an object.'
Here's my code:
--
System.Windows. Forms.RichTextB ox MyRTF = new
System.Windows. Forms.RichTextB ox();
MyRTF.LoadFile( "e:\\projects\\ iso\\hmm\\h.rtf ");

MyRTF.SelectAll ();

MyRTF.Copy();

System.Windows. Forms.IDataObje ct data =
System.Windows. Forms.Clipboard .GetDataObject( );

if (data.GetDataPr esent(System.Wi ndows.Forms.Dat aFormats.Rtf))

{

ftb.Text =
data.GetData(Sy stem.Windows.Fo rms.DataFormats .Rtf).ToString( );

}

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

Here is error:

--

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.NullRefe renceException: Object reference
not set to an instance of an object.

Source Error:

Line 67: ftb.ToolbarLayo ut = "Paste";
Line 68: System.Windows. Forms.IDataObje ct data =
System.Windows. Forms.Clipboard .GetDataObject( );
Line 69: if
(data.GetDataPr esent(System.Wi ndows.Forms.Dat aFormats.Rtf)) Line 70:
{
Line 71: ftb.Text =
data.GetData(Sy stem.Windows.Fo rms.DataFormats .Rtf).ToString( );
=============== ===============

Thanks for help.

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

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.