UrlPropertyAttribute question

B

Brent Pranger

I have developed a WebControl that has a "MyUrl" member property. I have
added the UrlPropertyAttribute attribute to the specific MyUrl member. Now,
when I edit the new element in the aspx page (Source view), the IDE (vs.net
2005 beta 1) intellisense will give me a "Pick Url..." option. However,
when I go to Design view and right-click, properties, the property does not
have the "..." button (in the property grid - for picking a URL) that I
would expect. Any ideas?

[UrlProperty()]
public String MyUrl {
get {
return (String)ViewState["MyUrl"];
}
set {
ViewState["MyUrl"] = value;
}
}

Thanks,
Brent
 
B

Brent Pranger

Thanks for the reply.. However, the property is already showing up in the
designer, it just doesn't provide the [...] button to invoke a URL browser
dialog (even though I can invoke said dialog from source-view ("Pick Url").

Any other ideas? Perhaps it's just a bug in the vs.net beta (although other
controls with URL properties seem to work fine).

Brent


Viksi said:
add [Browsable(true)] before the property
-Viksi

Brent Pranger said:
I have developed a WebControl that has a "MyUrl" member property. I have
added the UrlPropertyAttribute attribute to the specific MyUrl member.
Now,
when I edit the new element in the aspx page (Source view), the IDE
(vs.net
2005 beta 1) intellisense will give me a "Pick Url..." option. However,
when I go to Design view and right-click, properties, the property does
not
have the "..." button (in the property grid - for picking a URL) that I
would expect. Any ideas?

[UrlProperty()]
public String MyUrl {
get {
return (String)ViewState["MyUrl"];
}
set {
ViewState["MyUrl"] = value;
}
}

Thanks,
Brent
 
B

Brent Pranger

Well, I ended up downloading the Mono source code for the
System.Web.UI.WebControls.Image class from www.mono-project.com to see how
they did it (for the ImageUrl property). As it turns out, you must specify
the EditorAttribute class so that Visual Studio knows which "Editor" to use
for that property. The attribute I needed was:

[Editor(typeof(System.Web.UI.Design.UrlEditor),
typeof(System.Drawing.Design.UITypeEditor))]

Problem solved.

Brent


Brent Pranger said:
Thanks for the reply.. However, the property is already showing up in the
designer, it just doesn't provide the [...] button to invoke a URL browser
dialog (even though I can invoke said dialog from source-view ("Pick
Url").

Any other ideas? Perhaps it's just a bug in the vs.net beta (although
other controls with URL properties seem to work fine).

Brent


Viksi said:
add [Browsable(true)] before the property
-Viksi

Brent Pranger said:
I have developed a WebControl that has a "MyUrl" member property. I
have
added the UrlPropertyAttribute attribute to the specific MyUrl member.
Now,
when I edit the new element in the aspx page (Source view), the IDE
(vs.net
2005 beta 1) intellisense will give me a "Pick Url..." option. However,
when I go to Design view and right-click, properties, the property does
not
have the "..." button (in the property grid - for picking a URL) that I
would expect. Any ideas?

[UrlProperty()]
public String MyUrl {
get {
return (String)ViewState["MyUrl"];
}
set {
ViewState["MyUrl"] = value;
}
}

Thanks,
Brent
 

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

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top