Hi,
I have a situation where I have a user Control (ResultHeader.a scx) that has
a button. I am placing that control into a page (samplePage.asp x). I have
setup a custom event, that should from everything I read, it should fire and
be trappable in the parent page. I have seen two ways to do this...one
using "with Events" and the another by using the add handler method.
Neither seems to be functioning in my case. What am I doing wrong?
Thanks!
Ron
' SamplePage.aspx -- the actual page object
Public Class SamplePage
Inherits System.Web.UI.P age
Implements IResultContaine r
Protected WithEvents RR As Results
Protected WithEvents RH As ResultHeader
Private _Title As String
Public ReadOnly Property Title() As String Implements IResultContaine r.Title
Get
Return Page.ToString
End Get
End Property
Public ReadOnly Property Results() As IResult Implements
IResultContaine r.IResults
Get
Return RR
End Get
End Property
Public ReadOnly Property Header() As ResultHeader Implements
IResultContaine r.ResultHeader
Get
Return RH
End Get
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
RR = CType(Page.Load Control("Result s.ascx"), Results)
RH = CType(Page.Load Control("Result Header.ascx"), ResultHeader)
End Sub
Private Sub RH_Buttonclicke d(ByVal sender As Object, ByVal e As
System.EventArg s) Handles RH.ButtonClicke d
RH.CallbackTest ("test") <-- this line is never getting called
End Sub
End Class
' ResultHeader.as cx -- the user control that contains the button
Public Class ResultHeader
Inherits System.Web.UI.U serControl
Protected WithEvents DataGrid1 As System.Web.UI.W ebControls.Data Grid
Protected WithEvents TextBox1 As System.Web.UI.W ebControls.Text Box
Protected _Info As DataTable
Protected _Title As String
Protected WithEvents Button1 As System.Web.UI.W ebControls.Butt on
Protected WithEvents Label1 As System.Web.UI.W ebControls.Labe l
Protected _RowCount As String
Public Event ButtonClicked(B yVal sender As System.Object, ByVal e As
System.EventArg s)
Dim Container As IResultContaine r
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
If TypeOf (Page) Is IResultContaine r Then
Container = CType(Page, IResultContaine r)
_Title = Container.Title
_Info = Container.IResu lts.GetResults( _Title)
_RowCount = Container.IResu lts.GetRowCount (_Info)
BindGrid()
TextBox1.Text = _Title & " Returned " & _RowCount & " rows"
End If
AddHandler Button1.Click, AddressOf Button_Clicked
End Sub
Private Sub Button_Clicked( ByVal sender As System.Object, ByVal e As
System.EventArg s)
RaiseEvent ButtonClicked(s ender, e)
End Sub
Public Sub CallbackTest(By Val message As String) <--- this line is never
getting called
Label1.Text = message
End Sub
Private Sub BindGrid()
DataGrid1.DataS ource = (_Info)
DataGrid1.DataB ind()
End Sub 1 1749
Never mind I figured it out.
I never instantiated the RH and RR objects. I added the New keyword and
removed the "RR = CType(Page.Load Control("Result s.ascx"), Results)" lines
and everything works as expected.
Ron
"RSH" <wa************ *@yahoo.comwrot e in message
news:e9******** ******@TK2MSFTN GP06.phx.gbl...
Hi,
I have a situation where I have a user Control (ResultHeader.a scx) that
has a button. I am placing that control into a page (samplePage.asp x). I
have setup a custom event, that should from everything I read, it should
fire and be trappable in the parent page. I have seen two ways to do
this...one using "with Events" and the another by using the add handler
method. Neither seems to be functioning in my case. What am I doing
wrong?
Thanks!
Ron
' SamplePage.aspx -- the actual page object
Public Class SamplePage
Inherits System.Web.UI.P age
Implements IResultContaine r
Protected WithEvents RR As Results
Protected WithEvents RH As ResultHeader
Private _Title As String
Public ReadOnly Property Title() As String Implements
IResultContaine r.Title
Get
Return Page.ToString
End Get
End Property
Public ReadOnly Property Results() As IResult Implements
IResultContaine r.IResults
Get
Return RR
End Get
End Property
Public ReadOnly Property Header() As ResultHeader Implements
IResultContaine r.ResultHeader
Get
Return RH
End Get
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
RR = CType(Page.Load Control("Result s.ascx"), Results)
RH = CType(Page.Load Control("Result Header.ascx"), ResultHeader)
End Sub
Private Sub RH_Buttonclicke d(ByVal sender As Object, ByVal e As
System.EventArg s) Handles RH.ButtonClicke d
RH.CallbackTest ("test") <-- this line is never getting called
End Sub
End Class
' ResultHeader.as cx -- the user control that contains the button
Public Class ResultHeader
Inherits System.Web.UI.U serControl
Protected WithEvents DataGrid1 As System.Web.UI.W ebControls.Data Grid
Protected WithEvents TextBox1 As System.Web.UI.W ebControls.Text Box
Protected _Info As DataTable
Protected _Title As String
Protected WithEvents Button1 As System.Web.UI.W ebControls.Butt on
Protected WithEvents Label1 As System.Web.UI.W ebControls.Labe l
Protected _RowCount As String
Public Event ButtonClicked(B yVal sender As System.Object, ByVal e As
System.EventArg s)
Dim Container As IResultContaine r
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
If TypeOf (Page) Is IResultContaine r Then
Container = CType(Page, IResultContaine r)
_Title = Container.Title
_Info = Container.IResu lts.GetResults( _Title)
_RowCount = Container.IResu lts.GetRowCount (_Info)
BindGrid()
TextBox1.Text = _Title & " Returned " & _RowCount & " rows"
End If
AddHandler Button1.Click, AddressOf Button_Clicked
End Sub
Private Sub Button_Clicked( ByVal sender As System.Object, ByVal e As
System.EventArg s)
RaiseEvent ButtonClicked(s ender, e)
End Sub
Public Sub CallbackTest(By Val message As String) <--- this line is
never getting called
Label1.Text = message
End Sub
Private Sub BindGrid()
DataGrid1.DataS ource = (_Info)
DataGrid1.DataB ind()
End Sub
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Alphonse Giambrone |
last post by:
I have a web form with 2 user controls on it (UC1 and UC2).
Each control has a bound datagrid with textboxes in the footer to add a new
row. There are also requiredfieldvalidators in each footer.
When I try to add a new row to UC1 the requiredfieldvalidators for UC2 fire
and therefore the page is not posted.
If I remove one control, everything works fine.
I have 2 questions.
1. How can I get the validators for each control to only...
|
by: DotNetGuru |
last post by:
Hi,
I have nested User Controls like below.
User_Control_1
User_Control_11
User_Control_12(contains method DisplayMessage)
User_Control_2(contains event onButtonClick )
User_Control_1 and User_Control_2 are loaded in the PAGE_LOAD of a
|
by: luca |
last post by:
Hi all.
My problem is that I can't handle events raised from child components within
a composite server control when the control is created dynamically.
Everything works fine if the same control is defined within an aspx page
<MyTag:MyControl id="MyControl1" runat="server">: MyControl handle
succesfully events raised from its children.
When I try to create dynamically MyControl and to Add it to another control,
event handling doesn't work...
|
by: Kris van der Mast |
last post by:
Hi,
been a while since I posted a question myself instead of trying to help
others out.
I'm refactoring an existing web app that uses dynamic loading of user
controls and a lot of response.redirects to the same page. Because I hate
the overhead by doing this I'm searching for a cleaner option.
But I'm having troubles (off course or I wouldn't be posting this).
|
by: Robert Howells |
last post by:
Perhaps I'm just too new at this to pull it off, or perhaps it's just bad
architecture. I'd appreciate some feedback on the the wisdom (or lack
thereof) in attempting the following:
I'm not new to programming, but I am new to ASP.NET and Web application
design in general... loved the concept of user controls and dynamically
adding them to a page. So what I wound up with was an application that
dynamically loads two user controls directly...
| |
by: Steve Booth |
last post by:
I have a web form with a button and a placeholder, the button adds a user
control to the placeholder (and removes any existing controls). The user
control contains a single button. I have done all the usual stuff of
recreating the usercontrol in the Page Init event.
The 'failure' sequence is as follows:
- select web form button to display the user control
- select user control button, event fires
- select web form button to display...
|
by: scsharma |
last post by:
Hi,
I am working on creating a webapplication and my design calls for creating
main webform which will have menu bar on left hand side and a IFrame which
will contain all the forms that are shown when menu items are clicked.Besides
these i would like to put a custom status bar. Any error message encountered
in any of the webpage will be displayed in the banner.
The problem iam encountering is how to access the customer status bar in
child...
|
by: c676228 |
last post by:
Hi,
I guess I am confused. In aspx script, I mean (you won't use
Codebehind="enrollinfo.aspx.vb", but mix code with html and code together)
You can access user control's property directly. Since I am useing visual
studio .net,
the html and code are seperated.
I have the following aspx code which has two user controls:
<%@ Register TagPrefix="Subway" TagName="Peopleinfo" Src="Peopleinfo.ascx" %>
<%@ Register TagPrefix="Subway"...
|
by: ChrisCicc |
last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have been able to find the cause of the problem, and will describe it here first textually and then through a code example.
The purpose of what I am trying to do is to create a postback-free web application through the use of ASP.net AJAX UpdatePanels...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |