/// <summary>The iPopUp Control: an easy way to create PopUps
/// without writing the Client
/// Javascript Code. </summary>
public class iPopUp : WebControl
{
/// <summary>Enables or Disables the Scrollbars in the
/// opening PopUp</summary>
public bool Scrollbars = false;
/// <summary>Enables or Disables the Menubar in the
/// opening PopUp</summary>
public bool Menubar = false;
/// <summary>Enables or Disables the Locationbar in the
/// opening PopUp</summary>
public bool Locationbar = false;
/// <summary>Enables or Disables the possibility to
/// Resize the opening PopUp</summary>
public bool Resizeable= false;
/// <summary>Enables or Disables the Statusbars in the
/// opening PopUp</summary>
public bool Statusbar = false;
/// <summary>Toggles Fullscreen mode on or off. Maybe
/// unsupported in some Browsers.</summary>
public bool Fullscreen = false;
/// <summary>Gets or Sets the Top (y) Position of the
/// new PopUp</summary>
public Unit Top = new Unit();
/// <summary>Gets or Sets the Left (x) Position of the
/// new PopUp</summary>
public Unit Left = new Unit();
private string text = "";
/// <summary>Gets or Sets the Text which is displayed as
/// an Link to open the PopUp</summary>
public string Text
{
get { return text; }
set { text = value; }
}
/// <summary>Gets or Sets the URL to the Website which
/// will be opende inside the new PopUp</summary>
public string NavigateUrl
{
get
{
object obj = ViewState["NavigateUrl"];
return (obj == null) ? String.Empty :
(string)obj;
}
set
{
ViewState["NavigateUrl"] = value;
}
}
/// <summary>Gets or Sets the URL to an Image which will
/// be displayed as an Link to open the PopUp</summary>
public string ImageUrl = "";
/// <summary>Gets or Sets the Alternating Text (to the
/// ImageUrl Property) which will be displayed if
/// Images are disabled in the Browser.</summary>
public string AlternateText = "";
/// <summary>Used to create the Control</summary>
protected override void OnLoad (EventArgs e)
{
StringBuilder Options = new StringBuilder();
if (Fullscreen)
Options.Append("fullscreen = yes, ");
else Options.Append("fullscreen = no, ");
if (Scrollbars)
Options.Append("scrollbars = yes, ");
else Options.Append("scrollbars = no, ");
if (Menubar)
Options.Append("menubar = yes, ");
else
Options.Append("menubar = no, ");
if (Locationbar)
Options.Append("locationbar = yes, ");
else
Options.Append("locationbar = no, ");
if (Resizeable)
Options.Append("resizeable = yes, ");
else
Options.Append("resizeable = no, ");
if (Statusbar)
Options.Append("status = yes ");
else
Options.Append("status = no ");
if (!Left.IsEmpty)
Options.Append("left = " + Left.ToString() + ", ");
if (!Top.IsEmpty)
Options.Append("top = " + Top.ToString() + ", ");
if (!Width.IsEmpty)
Options.Append("width = " + Width.ToString() + ", ");
if (!Height.IsEmpty)
Options.Append("height = " + Height.ToString());
StringBuilder myString = new
StringBuilder("<script language=\"Javascript\">");
myString.Append("function PopUp_" +
this.ClientID + "() {");
myString.Append(" window.open(\"" +
ViewState["NavigateUrl"] + "\",\"Bildermanager\", \"" +
Options.ToString() + "\")");
myString.Append(" } </script");
myString.Append(">");
Page.RegisterClientScriptBlock("PopUp_" +
this.ClientID, myString.ToString());
}
/// <summary>Used to create the Control</summary>
protected override void Render( HtmlTextWriter writer)
{
if (ImageUrl != string.Empty)
{
text = "<img src=\"" + ImageUrl + "\\" +
" alt=\"" + AlternateText + "\" border=\"0\">" + text;
}
writer.Write("<a target=\"_self\" href=\"javascript:PopUp_"
+ this.ClientID + "()\">" + text + "</a>");
}
}