473,395 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

User control with events

I need to make a new user control; it will contain a button and a drop down
list.
Can I make the button click event handling editable by the user, like he can
specify the method that will handle this click event on the hosting page?
Sep 20 '06 #1
3 1456
http://msconline.maconstate.edu/tuto...pnet05-02.aspx

"Toty Santana" <To*********@community.nospamwrote in message news:A2**********************************@microsof t.com...
>I need to make a new user control; it will contain a button and a drop down
list.
Can I make the button click event handling editable by the user, like he can
specify the method that will handle this click event on the hosting page?

Sep 20 '06 #2
You can use collection of delegate objects in your control to execute hosted
page method based on your dropdown list selection.
Private _delegateObject As System.Delegate
Private _delegateObjects As New Collection
....
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
_delegateObject = _delegateObjects(Me.DropDownList1.SelectedIndex + 1)
_delegateObject.DynamicInvoke()
End Sub

....
Setup delegate collection (addresoff <function>)in your hosted form and pass
it to the control.

Let me know if it works for you


--
Programmer
"Toty Santana" wrote:
I need to make a new user control; it will contain a button and a drop down
list.
Can I make the button click event handling editable by the user, like he can
specify the method that will handle this click event on the hosting page?
Sep 20 '06 #3
Yes worked after a little tweeking, thank you ver much

in the user control class i declared the following

public delegate void dlgtAddButton();
public dlgtAddButton dlgt = null;

in the user control button click event handler

protected void btnEditList_Click(object sender, EventArgs e)
{
dlgt.DynamicInvoke();
//any other code that will be excuted anytime regardless of the
host page
}

and in the host page load handler

UC.dlgt = new UC.dlgtAddButton(PageMethod);
"Sergey Zuyev" wrote:
You can use collection of delegate objects in your control to execute hosted
page method based on your dropdown list selection.
Private _delegateObject As System.Delegate
Private _delegateObjects As New Collection
...
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
_delegateObject = _delegateObjects(Me.DropDownList1.SelectedIndex + 1)
_delegateObject.DynamicInvoke()
End Sub

...
Setup delegate collection (addresoff <function>)in your hosted form and pass
it to the control.

Let me know if it works for you


--
Programmer
"Toty Santana" wrote:
I need to make a new user control; it will contain a button and a drop down
list.
Can I make the button click event handling editable by the user, like he can
specify the method that will handle this click event on the hosting page?
Sep 21 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
1
by: Earl Teigrob | last post by:
PROBLEM: When a user control is loaded into a PlaceHolder control more than once, the events do not fire on the first click of a control on the dynamically loaded user control. In other words, the...
5
by: George Durzi | last post by:
I have a simple user control with a text box and a submit button. When the user enters some text into the textbox and clicks the submit button, a record is created in the database. I'm using...
10
by: George G. | last post by:
Hi there, I am busy writing a new asp.net application and I am reusing some of my existing asp functions and methods in a user control. I need access to session, request and response in some of...
4
by: thomson | last post by:
Hi all, i do have a user control with 4 buttons, and all the events are firing properly, My problem is that i need to right an event handler in the user control, which gets fired after a...
4
by: louise raisbeck | last post by:
Resending this as own topic as didnt get answer from original. Would be grateful for a response from anyone that knows. Thanks. Hi there, I found your post really helpful..but i wondered if, once...
6
by: Art | last post by:
Hi I'm new at this and need some help. I have a "solution" with 2 projects - the main project and a library. The library is simple, it contains a text box that will appear many times in the form...
1
by: Israel | last post by:
The problem: I want to know, definitively when a slider loses focus after a user has started sliding and hasn't released the mouse yet. It appears that this is captured with the WM_ACTIVATEAPP...
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.