select a url at design time

N

Neo

Hi all,

I have the following code from MSDN.But when I click a button in property
grid at design time, an error is popup:" Object refrence not set to an
instance of an object". Is there anything I missed?


<EditorAttribute(GetType(System.Web.UI.Design.ImageUrlEditor),
GetType(UITypeEditor))> _
Public Property imageURL() As String
Get
Return imgURL
End Get
Set(ByVal Value As String)
imgURL = Value
End Set
End Property

Thanks.

Neo
 
N

Neo

Hi,

Click that button, a dialog window will be pop up. I think maybe that window
is not initialized .
Please help me out here.Any points would be appreciated.

Neo
 
S

S.Sigal

Hi Neo:

If I am correctly understanding the problem...(50/50 at best with me :) )

What I was saying is you are focusing on looking for the error from the
attribute you put on it (ImageUrlEditor).

I think the error is coming from the private imgURL var that the Property Get/Set is looking
at. I think you may have Declared it -- but not instantiated it... so it's Null.

What you need to do is to instantiate it first :

a) In the class itself so that it runs on instantiateion of the class:
//Instantiate it first:
Dim imgUrl as new String()


(forgive me if the syntax is wrong in VB -- I program in C#).
in C# it's: private string imgUrl = string.Empty;

But you have to make the imgUrl SOMETHING before the ImageUrlEditor can
use it...Otherwise it groans/errors saying trying to edit a null, when it was designd to edit
a string?

Good luck,
Sky
 
N

Neo

Hi,

Thanks for reply. I tried your method.It did work.:(
And the problem has changed a bit.

I have the my class derived from webcontrol class. This time, there was no
response when I clicked the button,
even if an error message that displayed before.

Neo
 
N

Neo

Hi,

I am still stuck here.
I built a web server control which inheris webcontrol class. The control
has a property- ImageUrl and I applied a attribute
<EditorAttribute(GetType(System.Web.UI.Design.ImageUrlEditor),GetType(UIType
Editor))> on the property. The attribute shows a button which is used to
select a image url, like imagebutton's imageurl property.

My problem is when I click the button, there is no response.Did I miss
something?


Thanks.
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,900
Latest member
Nell636132

Latest Threads

Top