473,382 Members | 1,377 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,382 software developers and data experts.

How to assign a UserControl with the methods of its parent page?

Hi,

I have a UserControl called it <pm:task> and it's in Page1.

inside <pm:task> user control, I have 3 buttons, "create task", "edit
task", "delete task".

now I want to assign this <pm:task> this way in Page1..

protected void Create_Task_Function(object sender, EventArgs e)
{
}
....
protected void Update_Task_Function(object sender, EventArgs e)
{
}
....
protected void Delete_Task_Function(object sender, EventArgs e)
{
}

<pm:task onCreateTask_Clicked="Create_Task_Function"
onEditTask_Clicked="Update_Task_Function"
onDeleteTask_Clicked="Delete_Task_Fucntion"
runat="server"
/>

How could I create the UserControl such that when the buttons are
clicked, it delegates to the approriate functions on Page1 that has
been assigned to it?

Thanks

Apr 25 '06 #1
1 1046
Never mind I figured out. In case others wants to know...

Simply add

public event System.EventHandler CreateTask_Clicked;
public event System.EventHandler EditTask_Clicked;
public event System.EventHandler DeleteTask_Clicked;

to your user Control

and in your button click function, raise it.. for example

<asp:button id="CreateTask_Button" onClick="CreateTask" runat="server"
/>

protectec void CreateTask(object sender, EventArgs e)
{
if (this.CreateTask_Clicked!=null)
{
CreateTask_Clicked(this,e);
}
}

.... do the same thing for EditTaks and DeleteTask.
Hope this helps.

Apr 25 '06 #2

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

Similar topics

2
by: Lau Lei Cheong | last post by:
Hello, I'm writing a usercontrol that contains a property named "disabled". It is set to false by default but there is also another button in the usercontrol that'll set it to true. On the...
4
by: John | last post by:
Hi, is it possible for a UserControl to get the Page name and querystring of its parent? e.g If a userControl is inside a page called "index.aspx?ID=66" how can a usercontrol print out this...
4
by: Mat | last post by:
Hi, I am having a bit of a problem trying to access / set properties of a usercontrol from the parent codebehind. This is what I have so far.. simple.aspx <%@ Page...
6
by: Pete Davis | last post by:
I'm fairly weak with ASP.NET. What I'm trying to do is pass an attribute to a UserControl. The attribute is a value from the CodeBehind for the page. So in my .aspx I have the following: ...
0
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852...
0
by: davidr | last post by:
Hi, I've read about bubble events and setting up the event args and several other methods to have an event that occurs in a usercontrol flow up to the parent. The problem is each one entails a...
10
by: Benton | last post by:
Hi there, I have a UserControl with a couple of textboxes and a couple of buttons ("Save" and "Cancel"). The Click event for this buttons is in the UserControl's codebehind of course, so here's...
8
by: Tony Johansson | last post by:
Hello! I wonder can somebody explain when is it suitable to use these methods OnKeyUp, OnKeyDown and OnKeyPress because these raise an event. These are located in class UserControl. If these...
6
by: sundarvenkata | last post by:
Hi All, I have a custom UserControl that is used as the list item in a listbox in my main WPF window. Is it possible to have key bindings that apply to every instance of the user control? For...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.