Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 4th, 2005, 06:06 PM
Registered User
 
Join Date: Dec 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Web Custom Control Events

I created a web custom control which is derived from TextBox. I need to use the event OnTextChanged, but could not make it work. Similar code works for Button control.

To reproduce the problem, add the two custom controls to a webform. Add a break point sin the OnClick and OnTextChanged events and run the application.

I do not know what make the difference, and how to make the derived TextBox working.

Thank you very much for your help.

Jerry

Code for the derived textbox:

Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls

Public Class PBTextBox
    Inherits System.Web.UI.WebControls.TextBox

    Public Sub New()
        Me.Width = System.Web.UI.WebControls.Unit.Pixel(60)
    End Sub

    Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
        MyBase.OnTextChanged(e)
    End Sub

End Class

Code for the derived Button

Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls

' custom control derives from button
Public Class CountedButton
    Inherits System.Web.UI.WebControls.Button

    ' constructor initializes view state value
    Public Sub New()
    End Sub

    ' override the OnClick to increment the count,
    ' update the button text and then invoke the base method
    Protected Overrides Sub OnClick(ByVal e As EventArgs)
        'ViewState("Count") = CInt(ViewState("Count")) + 1
        MyBase.OnClick(e)
    End Sub
End Class

  #2 (permalink)  
Old May 3rd, 2007, 01:19 AM
Registered User
 
Join Date: May 2007
Location: , , India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ramprabu
Default

Hello,

   I am also facing this problem. But now i will solve that problem. You must set the property

                Control.IsPostback=true;

After that it raising all the events.

Thanks.

Regards
RAMPRABU

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Custom Events bendjoe BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 July 28th, 2008 03:07 PM
Web Service, Custom Control, Custom Return Type robzyc ASP.NET 2.0 Basics 6 June 10th, 2008 08:03 AM
Events for custom control in datarepeater?? lauriedthompson VB How-To 0 June 20th, 2007 05:11 AM
Maintaining the viewstate in a custom web control cridley C# 0 February 20th, 2006 07:55 AM
Web Custom Control prakashpatil_1978 ASP.NET 1.x and 2.0 Application Design 11 August 30th, 2004 07:35 AM



All times are GMT -4. The time now is 08:13 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.