Last post Jul 07, 2010 05:17 AM by drchanix
Jul 01, 2010 03:59 PM|lecedre|LINK
I have for example a modal popup control which I use as a wait screen so when a user click on a button, the client script show the modal popup and some background task are triggered and when the code is completed, it hides the modal popup. So far so good.
But I also develop application where I build my own custom control so I can use them everywhere.
I would like to try to convert this modal popup wait screen in custom server control. I saw that I could insert the js dynamically in the page if it's associate to the control but I wondering how to create a class that contains the panel, the modalpopup,
and eventually the hidden target button so that I can just add this control to my webpage in one shot and do not worry about creating this long pages. My focus is to be able to add it in different pages or different website without any limitation. May you
help or give me some links which would explain how to do this?
Jul 01, 2010 07:07 PM|nizam133|LINK
hey you need to create custom controls, you can check below posts how to create it
Jul 02, 2010 06:06 AM|lecedre|LINK
I try to do something like
/// Define a button in an update panel, then insert this object only once in the page,
public class WaitScreen : AjaxControlToolkit.ModalPopupExtender
protected override void OnLoad(EventArgs e)
Panel oPanel = new Panel();
oPanel.Height = new Unit(50);
oPanel.Width = new Unit(150);
oPanel.ID = "WaitScreenPanel";
oPanel.HorizontalAlign = HorizontalAlign.Center;
oPanel.BackColor = System.Drawing.Color.White;
Button oButton = new Button();
RoundedCornersExtender oRound = new RoundedCornersExtender();
oRound.ID = "WaitScreenRoundedCornersExtender";
oRound.TargetControlID = oPanel.ID;
oRound.Radius = 6;
oRound.Corners = BoxCorners.All;
oRound.Color = System.Drawing.Color.White;
oRound.BorderColor = System.Drawing.Color.Blue;
oButton.ID = "WaitScreenHiddenButton";
oButton.Text = "";
System.Web.UI.HtmlControls.HtmlImage img = new System.Web.UI.HtmlControls.HtmlImage();
img.Src = Page.ClientScript.GetWebResourceUrl(this.GetType(), "Web.Controls.Resources.wait.gif");
img.ID = "img";
img.Width = 50;
img.Height = 50;
this.PopupControlID = "WaitScreenPanel";
this.DropShadow = false;
this.OkControlID = "WaitScreenHiddenButton";
this.BackgroundCssClass = "modalBackground";
where I set the ID and the TargetControlId when I insert the control.
It works very well if I don't have master pages. As soon as I unclude masterpages, the code behind action map to my targetbutton is not triggered. Does somebody knows why?
Jul 05, 2010 11:34 PM|Qin Dian Tang - MSFT|LINK
Do you want the control like this:
Jul 07, 2010 05:17 AM|drchanix|LINK
Try adding an EventHandler to your button upon creating it.