.Net Links

Tuesday, October 20, 2009

Creating DevExpress Pop-UP Control in two Ways

Below is the code for creating simple Pop-Up Control in two ways using Code Behind.

Method1 Uses ASPxPopupControl.Controls collection :the default popup window will be used

Method 2 : User Created POp-UP window.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


using DevExpress.Web;
using DevExpress.Utils;
using DevExpress.Web.ASPxCallbackPanel;
using DevExpress.Web.ASPxEditors;
using DevExpress.Web.ASPxGridView;
using DevExpress.Web.ASPxPopupControl;


namespace WebApplication1
{
public partial class Grid_popUp : System.Web.UI.Page
{


protected void Page_Load(object sender, EventArgs e)
{

Method1();
Method2();

}

private void Method1()
{
ASPxPopupControl popupCtrl;
ASPxButton btnClick = new ASPxButton();

btnClick.ID = "btnID1";
btnClick.Text = "Pup-Up-1";
btnClick.AutoPostBack = false;

ASPxLabel lblShowUser = new ASPxLabel();
lblShowUser.Text = "Inside PopUP";

ASPxButton btn = new ASPxButton();
btn.Text = "Inside PopUP";

popupCtrl = new ASPxPopupControl();
popupCtrl.ID = "popupID1";
popupCtrl.ClientInstanceName = "popup";
popupCtrl.PopupElementID = "btnID1";

PopUpSettings(popupCtrl);


form1.Controls.Add(btnClick);
popupCtrl.Controls.Add(GetControl());
form1.Controls.Add(popupCtrl);
}

private void PopUpSettings(ASPxPopupControl popupCtrl)
{
popupCtrl.HeaderText = "My Header";
popupCtrl.Height = Unit.Pixel(300);
popupCtrl.Width = Unit.Pixel(100);
popupCtrl.CssFilePath = "~/_themes/Aqua/{0}/styles.css";
popupCtrl.CssPostfix = "Aqua";
popupCtrl.Left = 400;
popupCtrl.Top = 600;
popupCtrl.PopupAction = DevExpress.Web.ASPxClasses.PopupAction.LeftMouseClick;
popupCtrl.CloseAction = DevExpress.Web.ASPxClasses.CloseAction.CloseButton;
popupCtrl.PopupHorizontalAlign = DevExpress.Web.ASPxClasses.PopupHorizontalAlign.Center;
popupCtrl.PopupVerticalAlign = DevExpress.Web.ASPxClasses.PopupVerticalAlign.Middle;
}

private void Method2()
{
ASPxPopupControl popupCtrl;
ASPxButton btnClick = new ASPxButton();

btnClick.ID = "btnID2";
btnClick.Text = "Pup-Up-2";
btnClick.AutoPostBack = false;

ASPxLabel lblShowUser = new ASPxLabel();
lblShowUser.Text = "Inside PopUP";
PopupWindow pw = new PopupWindow();
pw.Controls.Add(lblShowUser);

popupCtrl = new ASPxPopupControl();
popupCtrl.ClientInstanceName = "popup";
popupCtrl.ID = "popupID2";

PopUpSettings(popupCtrl);


popupCtrl.Windows.Add(pw);
popupCtrl.Windows[0].PopupElementID = "btnID2";

form1.Controls.Add(btnClick);
form1.Controls.Add(popupCtrl);
}
Control GetControl()
{
TextBox txt = new TextBox();
txt.ID = "txt";
txt.Width = 200;
txt.Text = "Dynamic control";

return txt;
}

}
}

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]



<< Home