using System;
using System.Data;
using Microsoft.ApplicationBlocks.Data;
using System.Data.SqlClient;
using System.Web.UI;
namespace umbraco.macroRenderings
{
///
/// Summary description for content.
///
public class content : System.Web.UI.WebControls.WebControl, interfaces.IMacroGuiRendering
{
private string m_value = "";
public bool ShowCaption
{
get {return true;}
}
public string Value
{
get {
if (Page.IsPostBack && !String.IsNullOrEmpty(System.Web.HttpContext.Current.Request[this.ClientID])) {
m_value = System.Web.HttpContext.Current.Request[this.ClientID];
}
return m_value;
}
set { m_value = value; }
}
protected override void OnInit(EventArgs e) {
base.OnInit(e);
base.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ajax", "");
base.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ajax1", "");
base.Page.ClientScript.RegisterClientScriptBlock(GetType(), "subModal", "");
// We need to make sure we have a reference to the legacy ajax calls in the scriptmanager
ScriptManager sm = ScriptManager.GetCurrent(Page);
ServiceReference legacyPath = new ServiceReference(GlobalSettings.Path + "/webservices/legacyAjaxCalls.asmx");
if (!sm.Services.Contains(legacyPath))
sm.Services.Add(legacyPath);
}
public content()
{
//
// TODO: Add constructor logic here
//
}
protected override void Render(System.Web.UI.HtmlTextWriter writer) {
string tempTitle = "";
string deleteLink = " " + ui.Text("delete") + " ";
try {
if (this.Value != "") {
tempTitle = new cms.businesslogic.CMSNode(int.Parse(this.Value)).Text;
}
} catch { }
writer.WriteLine("");
// Clear remove link if text if empty
if (this.Value == "")
deleteLink = "";
writer.WriteLine("" + tempTitle + "" + deleteLink + "" + ui.Text("choose") + "... ");
base.Render(writer);
}
/*
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
string label = "";
if (this.Value != "")
{
SqlDataReader pageName = SqlHelper.ExecuteReader(umbraco.GlobalSettings.DbDSN,
CommandType.Text, "select text as nodeName from umbracoNode where id = " + this.Value);
if (pageName.Read())
label = pageName.GetString(pageName.GetOrdinal("nodeName")) + "
";
pageName.Close();
}
writer.WriteLine("" + label + "");
writer.WriteLine("Choose item");
writer.WriteLine("");
}*/
}
}