Solved

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

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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 this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

623 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