Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

IExtenderProvider for ASP.NET server control?

1 view
Skip to first unread message

Paul Easter

unread,
Mar 7, 2003, 11:34:01 AM3/7/03
to
I am trying to develop a server control that is a property extender. I can't
seem to get the properties to save in the code (HTML view). Does anyone have
an example of a working server control that implements IExtenderProvider? If
not what is the trick to get the values to be saved on the extended
property? TIA

Paul Easter


Andy Smith

unread,
Mar 7, 2003, 4:29:56 PM3/7/03
to
My DefaultButtons control implements it.
http://www.metabuilders.com/tools/DefaultButtons.aspx

__
Andy Smith

"Paul Easter" <pea...@leadsonline.us> wrote in message
news:uUnVddM5...@TK2MSFTNGP09.phx.gbl...

Paul Easter

unread,
Mar 10, 2003, 6:04:12 PM3/10/03
to
Thanks for the link. However, this control is doing (not doing) the same
thing mine is. If i click on a asp text input field and type a value for the
"DefaultButton on defaultButtons1" property, it is not saved to the code
(the HTML view). I have to manually add each "setting" via the settings
collection editor, which defeats the entire purpose of the IExtender
implementation. Also, if I change a property on the "DefaultButtons" control
via the property grid, it will then write its settings to the code, but it
won;t do it if you just type values in "extended" property on the text
inputs. Am i doing something wrong? TIA.

Paul

"Andy Smith" <ACSmith.T...@mactec.com> wrote in message
news:uya51CP5...@TK2MSFTNGP12.phx.gbl...

Andy Smith

unread,
Mar 10, 2003, 6:42:53 PM3/10/03
to
hrm.
I don't remember anybody emailing me about this issue, and I think somebody
would have by this time.
maybe it doesn't actually work tho :)

I'll look into it a bit.

__
Andy Smith

"Paul Easter" <pea...@leadsonline.us> wrote in message

news:e6mCgl15...@TK2MSFTNGP12.phx.gbl...

Paul Easter

unread,
Mar 10, 2003, 7:10:04 PM3/10/03
to
What is happening in these IExtenderProvider for asp.net controls is that
during the "Set[PropertyName]" method, values are being changed on the
extender via the extendee. What I have found is that when a control sets the
property of another control, the designer is not notified of that change (or
it is just not doing anything about it). You must explicitly tell the
designer that the control has changed so it can save its updated values to
code (HTML view). This is how it is done:


'Tell the designer that the component has changed
' Make sure we are in design mode
If Not Me.Site Is Nothing AndAlso Me.Site.DesignMode Then
Try
' Set up variables we need
Dim host As System.ComponentModel.Design.IDesignerHost
Dim changer As
System.ComponentModel.Design.IComponentChangeService
' Get the host from the site object
host =
CType(Me.Site.GetService(GetType(System.ComponentModel.Design.IDesignerHost)
), System.ComponentModel.Design.IDesignerHost)
' Get the change service from the host
changer =
CType(host.GetService(GetType(System.ComponentModel.Design.IComponentChangeS
ervice)), System.ComponentModel.Design.IComponentChangeService)
' raise the OnComponentChanged to tell the designer that
it our component has changed. "Me" in this case is the component that has
changed.
changer.OnComponentChanged(Me, Nothing, Nothing,
Nothing)
Catch ex As System.Exception
' hopefully we will never see this error
System.Windows.Forms.MessageBox.Show("Error: " &
ex.Message)
End Try
End If


I hope this helps someone.

Paul Easter

"Andy Smith" <ACSmith.T...@mactec.com> wrote in message

news:uOWiH715...@TK2MSFTNGP12.phx.gbl...

Andy Smith

unread,
Mar 11, 2003, 1:16:46 PM3/11/03
to
Great code snippet. I'll check it out in a few hours.
The only thing I don't like about this is that I have to put design time
code in my control that is made for a specific designer.
Can you think of any way to do this from the designer class associated with
the control?
I was thinking of an event that the designer could catch and alert the Site,
but then I've still cluttered my control with design time events that won't
mean anything to somebody using the control.

__
Andy Smith


"Paul Easter" <pea...@leadsonline.us> wrote in message

news:uLPVSK25...@TK2MSFTNGP12.phx.gbl...

Paul Easter

unread,
Mar 11, 2003, 2:33:28 PM3/11/03
to
I agree, it would be nice if everything worked the way it is supposed to.
The problem is that when a "user" is editing the extended property, the
designer of the extender control is not being used (I am pretty sure of this
because I overrode just about every method in the designer to see if it was
"alive" when editing the extended property), so the designer will actually
never have the opportunity to step in and make things happen. The root of
the problem is that the designer host (Visual Studio) is not aware that a
property has changed on a control unless it is told so. What is needed is
some kind of IPropertyChangeNotification interface that a control can
implement and to send out event message when a property has changed. That
way the design host (Visual Studio) can subscribe to these events (if the
control implements them) and respond accordingly when the event is raised.
That way if your control's properties are being manipulated by another
control in design view, your control can tell the designer host "hey my
properties have changed, you need to re-write my HTML and attributes". But
the IPropertyChangeNotification interface does not exist, and even if we
made one up, Visual Studio would not know to subscribe to it; so for now the
best way I can think of is the way I stated earlier by calling the
"OnComponentChanged" method on the design host services. I'd like to know
for sure if the extender control's designer is being used or not when an
extended property is being edited on an "extended" control.

Paul Easter

"Andy Smith" <ACSmith.T...@mactec.com> wrote in message

news:OaBtpq$5CHA...@TK2MSFTNGP11.phx.gbl...

0 new messages