I had a user control embedded in an ASPX (parent) page as a hidden layer. The control was placed inside of a panel control that was hidden. The parent page would load an show the user control
Once the user completed the work they clicked "Close Window" that would raise an event on the parent page, and the parent page would hide the hidden layer.
1. User Control (ASCX): Add the following delegates and events
// Delegate declaration
public delegate void OnButtonClick(string strValue);
// Event declaration
public event OnButtonClick btnHandlerEditAccount;
2. User Control (ASCX): Button close event will raise btnHandlerEditAccount causing the parent page to hide the panel with the user control.
protected void BtnCloseWindow_Click(object sender, EventArgs e)
//Make the parent close the window
if (btnHandlerEditAccount != null) btnHandlerEditAccount(string.Empty);
3. Parent Page: Handles btnHandlerEditAccount from the user control.
//Event Handlers to close windows from user controls (place in Page_Load)
UCEditAccountInfo.btnHandlerEditAccount += new EditAccountInfo.OnButtonClick(UCEditAccount_btnHandler);
//Syntax of item above: UserControlName dropped on the page += new Class.NameOfActualUserControl.OnButtonClick(handler created in step 1)
/// Handle the Window Close on the Edit Account User Control
protected void UCEditAccount_btnHandler(string strValue)
PnlGrid.Enabled = true;
PnlAccountEdit.Visible = false;
To get the full application path (for example to a folder named Documents) in ASP.NET do the following.
1. If you are on a webpage you can use the request object.
string DocPath = Request.MapPath(@"/Documents/");
2. If you are in a class you can use HTTPContext
string DocPath = HttpContext.Current.Request.MapPath(@"/Documents/");
You have an ASP.NET ListBox and you want to be able to allow users to Double Click on the list box to select items. You can add a hidden button to your page and then add a double click event to the list box to select items as shown below.
//Setup a string that will call a hidden button click event
string BntListBoxClick = "document.getElementById('"
+ BtnAddToTarget.ClientID.ToString() + "')"
//Add the double click event to the list box