Source Not Updating

imaginationx

New member
Joined
Oct 6, 2006
Messages
3
Programming Experience
5-10
Hello all,

I have a issue that is driving me insane, but Im sure some of you will have a quick fix for. I am creating a custom server control for a simple hover over imagebutton that will change images when the user drags the mouse over. Most of that is no problem. The issue is in Visual Studio Designer during design time.

I would like to have default images available that when selected automatically reset any previously selected images to the string "Default". This works fine in the Property Grid, but the underlying source cde does not get updated. Here is the code I am using:


'Defalt Enumerations
Public Enum EnumSkin
Custom = 0
View = 1
Edit = 2
Delete = 3
Email = 4
Print = 5
End Enum

'The Default
<Category("xButton Behavior")> <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)

ViewState("DefaultSkin") = value
End Set
End Property

'The Hover Image
<Category("xButton Image (Hover)")> <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"
Else
ViewState("DefaultSkin") = EnumSkin.Custom
End If

ViewState("ImageOnHover") = value
End Set

End Property


The code highlighted in Bold Red above is where my issue is. I am trying to set the "DefaultSkin" Property to "Custom" when an image is selected. This works fine on the Property Grid of Visual Studio 2005, but the source code does not update.

Any help would be GREATLY apprecated. Thanks in advance...
Jason
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,605
Location
Norway
Programming Experience
10+
What do you mean by this in property Set: value = "Default" - nothing will come from that. 'value' here is what is inputted by user, not something you change and return, that is what the property Get is for.
 

imaginationx

New member
Joined
Oct 6, 2006
Messages
3
Programming Experience
5-10
This actullay brings the word "default" into the property grid for the property when set. If set to default, then all it does is show the user that the default image will be used. Its just a faux value instead of having a blank property box.

Thanks...
Jason
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,605
Location
Norway
Programming Experience
10+
No. It is always the property Get that returns anything from a property. If you see anything reflecting the value of a property you can take it for granted it is the Get that returned that value. So changing the inputted 'value' variable of a property Set is meaningless.
 
Top Bottom