Solved

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

Posted on 2004-08-09
3
876 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

760 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

19 Experts available now in Live!

Get 1:1 Help Now