Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 13th, 2005, 08:31 AM
Registered User
 
Join Date: Jun 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default frustrating trouble with events and placeholder

Hi

I picked an example from the internet to show my problem. I add a linkbutton to a placeholder and add a handler 'bt.Click' for an event 'HandleEvent'. The event itself should now be in effect:
Private Sub HandleEvent(ByVal sender As Object, ByVal e As System.EventArgs) handles bt.Click

I understand that from this point I can leave out the 'handles bt.Click'. This is exactly what I want, because in real life I do not know in front the name of the LinkButton. But the event does not fire without a 'handles whatevercontrol.click'. There are many many examples of events on internet without a 'handles' clause, but why does this never work with me?

When I add 'handles MyBase.init', within the event i can get the name of the page (sender.ID = the name of the page), but not of the control (the linkbutton or dropdownlist).

I actually do not add linkbuttons in my placeholder, but some dropdownlists. So my event should handle dropdownlist.SelectedIndexChange. But I have the same trouble.

Any ideas are highly appreciated!!

Sub SimpleSub
   Dim bt As New LinkButton
   With bt
      .Text = "MyButton"
      .ID = "MyButtonID"
      .CommandName = "TheCommand"
   End With
   AddHandler bt.Click, AddressOf HandleEvent
   placeHolder.Controls.Add(bt)
End Sub


Private Sub HandleEvent(ByVal sender As Object, ByVal e As System.EventArgs)
   Response.Write(sender.CommandName)
End Sub






Similar Threads
Thread Thread Starter Forum Replies Last Post
Placeholder grstad ASP.NET 2.0 Basics 6 May 23rd, 2008 09:03 AM
Navigate away from a Content Placeholder slbibs SharePoint Development 0 September 4th, 2007 03:28 PM
placeholder controls rocksbhavesh ASP.NET 1.0 and 1.1 Professional 3 May 17th, 2007 08:11 AM
Problems with placeholder and textboxes sean ASP.NET 1.0 and 1.1 Professional 0 January 13th, 2004 11:49 AM
frustrating if then quandry through recordset monstermash Classic ASP Basics 5 July 18th, 2003 06:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.