Hello all,
I am creating my first custom server control for a simple imagebutton that allows mouse over effects. I have most everything working, except for the following:
I would like to allow the use of default images in design view, as well as let the programmer use their own images.
Defaults:Custom
View
Edit
Delete
Print
Email
If they select a Default I would like the ImageHover property to be set to 'Default'
The Problem: Using my code below, the property grid will switch the default back to "Custom", however the underlying source will not. The text highlighted in yellow below is where I attempt to set the ImageHover Property to Default.
My Code:
'--------------------------------------------------------
'List Of Default Button Skins
'--------------------------------------------------------
Public Enum EnumSkin
Custom = 0
View = 1
Edit = 2
Delete = 3
Email = 4
Print = 5
End Enum
<Category(
"Button Images")> <Browsable(True)> <Description("Use A Default Skin.")> <Bindable(True)> _
Public Property DefaultSkin() As EnumSkin
Get
Dim x As String = Convert.ToInt32(ViewState("DefaultSkin"))
Return x
End Get
Set(ByVal value As EnumSkin)
If value <> EnumSkin.Custom Then
ViewState("ImageOnHover") = "Default"
End If
ViewState("DefaultSkin") = value
End Set
End Property
'--------------------------------------------------------
'The Hover Image Displayed On Button
'--------------------------------------------------------
<Category("Button Images")> <Browsable(True)> <Description("Image that is displayed when the mouse hovers over the button.")> <Editor(GetType(System.Web.UI.Design.UrlEditor), GetType(System.Drawing.Design.UITypeEditor))> _
Public Property ImageOnHover() As String
Get
Dim x As String = Convert.ToString(ViewState("ImageOnHover"))
Return x
End Get
Set(ByVal value As String)
'Set To Default If Not Entered
If (Trim(value) = "") Or (value.ToLower = "default") Then
value = "Default"
End If
ViewState("ImageOnHover") = value
End Set
End Property
This code will update the property grid in design view, but will not update the underlying source. Any help would be greatly appreciated. Thanks in advance, and have a good day.
Jason Del Giudice