There is an error with the object MybutonCliecked(sender, e)
I am ataching my code....
..Thanks for your help
ps: Why Do I need "update panels/triggers configured"? I've the script manager in my html code but not the update panel, Do I need it and where suppose I need to set it up.Thanks
My web usercontro.ascx.cs:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class controls_Exampletry : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
public event CommandEventHandler MyButtonClicked;
public void MyButton_Click(object sender, EventArgs e) { MyButtonClicked(sender, e); }
public Panel StepPanel
{
get { return ContentPanelStep; }
}
void MyButtonClick(object sender, EventArgs e)
{
//do your stuff here
}
}
My .ascx from my web user control:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Exampletry.ascx.cs" Inherits="controls_Exampletry" %>
<asp:Panel ID="ContentPanelStep" runat="server">
<asp:Button ID="Button1" runat="server" Text="Testing" OnClick="MyButton_Click" />
</asp:Panel>
My ASPX.cs Page:
public partial class Insidemasterpage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HtmlTableRow stepRow = new HtmlTableRow();
HtmlTableCell stepCell = new HtmlTableCell();
controls_Exampletry myControl = (controls_Exampletry)Page.LoadControl("controls/Exampletry.ascx");
myControl.MyButtonClicked += new CommandEventHandler(MyButtonClick);
myControl.ID = "MyControl1";
//controls_NewHireWorkflowStepControl myHeaderControl = (controls_NewHireWorkflowStepControl)Page.LoadControl("controls/NewHireWorkflowStepControl.ascx");
// myHeaderControl.ID = "MyHeaderControl1";
//panel1.Controls.Add(myControl);
AjaxControlToolkit.CollapsiblePanelExtender cpe1 = new AjaxControlToolkit.CollapsiblePanelExtender(); cpe1.ID = "CollapsiblePanelExtender";
cpe1.TargetControlID = myControl.StepPanel.ClientID;
cpe1.SuppressPostBack = false;
// cpe1.ExpandControlID = myHeaderControl.StepHeaderPanel.UniqueID;
//cpe1.CollapseControlID = myHeaderControl.StepHeaderPanel.UniqueID;
//cpe1.BehaviorID = "CPEBehavior";
// cpe1.Collapsed = true;
//cpe1.AutoCollapse = false;
//cpe1.AutoExpand = false;
//cpe1.ScrollContents = false;
//cpe1.ExpandDirection = AjaxControlToolkit.CollapsiblePanelExpandDirection.Vertical;
// stepCell.Controls.Add(myHeaderControl);
stepCell.Controls.Add(myControl);
stepCell.Controls.Add(cpe1);
stepRow.Cells.Add(stepCell);
StepsTable.Rows.Add(stepRow);
}
}
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83:





by: ShazbotOKPosted on 2008-11-06 at 07:33:15ID: 22896057
Ok if your PAGE is attempting to capture the event from the User Control then you need to create event delegates in the user control then attach the event handler to the events from the PAGE code.
On a side-note I noticed your using the AJAX toolkit, be sure you have a defined scriptmanager in the markup AND update panels/triggers configured.
Select allOpen in new window