Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-08-09
3
Medium Priority
?
919 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 16

Accepted Solution

by:
RobertRFreeman earned 1000 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 1000 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

670 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