views:

68

answers:

1

Dear All,

I am making a custom ImageButton Control which has the option to show button clicked effect by adding onmouseup and onmousedown javascript code to change image URL. I have constructed the control and it has a ClickImageUrl to set the URL of image to be shown when button is clicked..

i wanted to know is there any way i can add a Select URL dialog box for my control just like the Dialog box for ImageUrl. is it even possible??? and if so how would i go about doing it...??

any help will be much appreciated.

EDIT: based on the answer by Arther i am able to show a Select Image URL diaolog box when i use it to set ClickImageUrl it shows a designer error as :

Error Rendering Control *An unhandled exception has occured* '~/images/7.jpg' cannot be set on property 'ClickImageUrl'

is it conflicting with the ImageUrl ???

+1  A: 

If your talking about the VS Designer, then you have to decorate your Property with these Attributes:

public class CustomImageButton : System.Web.UI.WebControls.ImageButton
{
    [Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
    [UrlProperty]
    public string ClickImageUrl { get; set; }
}
Arthur
thanks a lot...works like a charm...but when i use it to set the ClickImageUrl it shows an error in the designer..Error Rendering control..An unhandled exception has occured "~/images/7.jpg" cannot be set on property ClickImageUrl...any idea why it is so...???
Pankaj Kumar
also how did find about this..is it documented somewhere?? bcoz it seems quite hard to remember??
Pankaj Kumar
@Error: Maybe you are doing some work in your setter which could lead to design time errors.@Find out: Simple: Write ImageButton in your code, then right click -> goto definition. The definition of ImageButton will be shown. Then goto ImageUrl and expand the comments and attributes - here it is!
Arthur
thanks once agian, @Error: ok, i will check my setter
Pankaj Kumar