I wrote a user control in which I am creating grid inside PanelBar dynamically.
In New ItemTemplate I am creating grid and adding handler for Grid_rowdrop event.
So, my ASCX.VB FILE has code like below
MyUserControl.ASCX File:
Protected Class MyUserControl
Inherits System.Web.UI.Control
RadPanel_ItemDataBound Event
locationsPanel.ItemTemplate = new MyTemplateClass()
End Class
Class MyTemplateClass
Implements ITemplate
Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements System.Web.UI.ITemplate.InstantiateIn
' Create Dynamic RadGrid here
' and add RowDrop handler.
End Sub
Protected Sub MyDynamicGrid_RowDrop(ByVal sender As Object, ByVal e As GridDragDropEventArgs)
' I WANT TO CALL THIS EVENT FROM ASPX PAGE ON BUTTON CLICK. WHICH IS OUTSIDE OF THIS USERCONTROL
' AND OFCOURSE NOT PART OF THIS DYNAMIC GRID
End Sub
End Class
How to call/Raise "MyDynamicGrid_RowDrop" Event from ASPX page?
asppick
Member
494 Points
516 Posts
User control - event exposed to page (raise manually)
Sep 22, 2009 02:07 AM|LINK
Hi,
I wrote a user control in which I am creating grid inside PanelBar dynamically.
In New ItemTemplate I am creating grid and adding handler for Grid_rowdrop event.
So, my ASCX.VB FILE has code like below
MyUserControl.ASCX File:
How to call/Raise "MyDynamicGrid_RowDrop" Event from ASPX page?
Thanks
karthicks
All-Star
31376 Points
5421 Posts
Re: User control - event exposed to page (raise manually)
Sep 22, 2009 04:04 AM|LINK
hi, in user control you need to declare event and that should be raised in "MyDynamicGrid_RowDrop" event and you can use
this event in the Page
search in this forum ... already has been discussed
Karthick S
asppick
Member
494 Points
516 Posts
Re: User control - event exposed to page (raise manually)
Sep 22, 2009 01:46 PM|LINK
I couldn't find the relavent code.. any one can help?
asppick
Member
494 Points
516 Posts
Re: User control - event exposed to page (raise manually)
Sep 23, 2009 02:25 AM|LINK
Also,I am bit confused because the RowDrop event is inside another class of usercontrol..
Gary yang - ...
All-Star
25901 Points
2588 Posts
Re: User control - event exposed to page (raise manually)
Sep 24, 2009 05:13 AM|LINK
Based on my experience, I suggest you solve it by using Delegate. Please refer to the following articles to get some ideas:
http://chiragrdarji.wordpress.com/2007/08/23/raise-event-from-user-control-to-main-page-event-delegation-from-user-control-to-aspx-page-in-aspnetc/
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
karthicks
All-Star
31376 Points
5421 Posts
Re: User control - event exposed to page (raise manually)
Sep 24, 2009 05:37 AM|LINK
hi,
in usercontrol1 define event like below
delegate void ButtonClick(Object sender, EventArgs e);
public
public event ButtonClick OnButtonClick;
if (this.OnButtonClick!= null)
public void BubbleclickButtonClick(object sender, EventArgs e)
{
this.OnButtonClick(sender, e);}
In page code like below
public partial class Default: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.UserControl1.OnButtonClick+= new UserControl1.ButtonClick (UserControl1_OnButtonClick);
}
void UserControl1_OnButtonClick(object sender, EventArgs e)
{
// write your code to update other control textbox using property
}
Karthick S