Solved

Implementing IPostBackDataHandler in a custom web control that inherits from DropDownList with Visual Basic

Posted on 2004-08-09
3
879 Views
Last Modified: 2013-11-25
I have created a custom class with Visual Basic that inherits from the drop down list web control.  In order to update the value properly, I have tried to implement IPostBackDataHandler, but receive the following error message:

Interface 'System.Web.UI.IPostBackDataHandler' is already implemented by base class 'System.Web.UI.WebControls.DropDownList'.

My code is as follows:

Imports System.Web.UI

Public Class CodeDescDropDown
    Inherits System.Web.UI.WebControls.DropDownList
    Implements INamingContainer
    Implements IPostBackDataHandler

    Protected Overrides Sub Render(ByVal output as System.Web.UI.HtmlTextWriter)
        Mybase.Render(output)
    End Sub

   'Class implementation

End Class

For some reason, this error is not created if I use C# to write the class, but I really want to use VB.  Please let me know if you need more information.  Thanks for the help.
0
Comment
Question by:UFCWIT
3 Comments
 
LVL 16

Accepted Solution

by:
RobertRFreeman earned 250 total points
ID: 11758152
:)  I believe the answer is:

Interface 'System.Web.UI.IPostBackDataHandler' is already implemented by base class 'System.Web.UI.WebControls.DropDownList'

Since you are inheriting from the dropdownList control, you are already implenting the interface.  You will automatically get the postback data.  You should override the onLoad or onInit methods if you need to do something custom onload or oninit.  Then call back to mybase.onLoad or mybase.onInit.

C#'s not as smart as VB. lol.
0
 
LVL 21

Assisted Solution

by:tovvenki
tovvenki earned 250 total points
ID: 11759488
Hi,
In general if you want a server control you design to examine form data that is posted back to the server by the client, you must implement the IPostBackDataHandler interface. The contract that this interface defines allows a server control to determine whether its state should be altered as a result of the post back, and to raise the appropriate events.
The server controls available with asp.net  already implments this interface so you don't need to implement this interface again. Have a look at this url
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebUIIPostBackDataHandlerClassTopic.asp

Regards,
Venki
0
 

Author Comment

by:UFCWIT
ID: 11761940
Thanks, guys.  It turns out that I was calling Page.RegisterRequiresPostBack in the wrong place.  I did it in the control's PreRender event, which is too late.  I had overridden the Init event and suppose I lost it there by doing so.  Anyways, I moved it to the Init event and it works fine.  Thanks again.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now