using System;
using System.IO;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls; //nicht benötigt?
using System.Xml.Serialization;
using System.Globalization;
using System.ComponentModel;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
namespace ColoredEntries
{
[Guid("ec3aa31c-65ef-45f9-89a4-d4081fa19588")]
[CLSCompliantAttribute(false)]
//neu Microsoft.SharePoint.WebPartPages.WebPart
//alt System.Web.UI.WebControls.WebParts.WebPart
public class ColoredEntries : Microsoft.SharePoint.WebPartPages.WebPart
{
private const string defaultText = "";
private string text = defaultText;
private const string JCodeFileName = "myCode1.js";
private const string JCodeIncludeScriptKey = "myJCodeIncludeScript";
private const string IncludeScriptFormat = @"<script language=""{0}"" src=""{1}{2}""></script>";
public ColoredEntries()
{
Debug.WriteLine("Test1");
this.PreRender += new EventHandler(ColoredEntries_PreRender);
}
[Browsable(true), Category("Miscellaneous"),
DefaultValue(defaultText),
WebPartStorage(Storage.Personal),
FriendlyName("Text"), Description("Text Property")]
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}
private void ColoredEntries_PreRender(object sender, System.EventArgs e)
{
Debug.WriteLine("Test2");
RegisterCommonScript();
}
protected void RegisterCommonScript()
{
Debug.WriteLine("Test3");
//string location = null;
if (!Page.IsClientScriptBlockRegistered(JCodeIncludeScriptKey))
{
String location = this.ClassResourcePath + "/";
Debug.WriteLine(this.ClassResourcePath);
// Create the client script block.
string includeScript = String.Format(IncludeScriptFormat, "javascript", location, JCodeFileName);
Debug.WriteLine(includeScript);
Page.RegisterClientScriptBlock(JCodeIncludeScriptKey, includeScript);
Debug.WriteLine(JCodeIncludeScriptKey);
Debug.WriteLine(includeScript);
}
//typen auf neu aktualisieren!
}
protected override void CreateChildControls()
{
base.CreateChildControls();
}
protected override void RenderWebPart(HtmlTextWriter output)
{
//Ausgabe mit Button
output.Write("<br><input class='ms-SPButton' value=\'Klick mich\' type=button onclick=\"Code();\" >");
//output.Write("<\"Code();\">");
//Page.RegisterStartupScript("mycode", includeScript);
Debug.WriteLine("ende");
}
/*
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
}
*/
}
}