Solved

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

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# LINQ ForEach() question 6 76
I need help adding validation to my MVC.Net view 6 21
Data organization issue 7 36
Web page design problem 3 12
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

685 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