Feeds:
Tulisan
Komentar

myTemplateUI is a tools that I developed by .NET environment which is coordinating many standard functions in application such as Insert, Update, Delete, Searching, Navigator, etc, in just one place. myTemplateUI will help the web developer to make a page more faster and also we can maintain the application more easier because many global function can put in just one place. So if there is any changes in one function that put it in myTemplateUI so it will affecting to all pages that already build without changing all pages that using the function. Basicly the web developer only focus on Database programming. This tools can use by any kind of system. This tools already using Ajax technology.

If we can check the version and type of the browser so we can manage our application to a certain browser. This is the code of how to check the browser.

Request.Browser.Type –> to check the type of the browser (IE, Mozilla, Opera, etc)
Request.Browser.MajorVersion –> to check the version of the browser

Property Editor adalah sebuah editor bagi sebuah property dimana property tersebut merepresentasikan sebuah object list. Sehingga developer dapat menentukan behaviour dari sebuah control yang sedang dibuat dapat dilakukan pada saat design time. .NET sudah menyediakan sebuah Class “CollectionEditor” yang merupakan hasil inherits dari UITypeEditor, dengan kita meng-inherits Class CollectionEditor kita dapat meng-override method-method yang tersedia untuk disesuaikan dengan kebutuhan kita.

Saya akan berikan contoh yang sangat sederhana dibawah ini :

Class : ContohCollectionEditor.cs

// Class ini adalah sebuah class yang meng-inherits Class CollectionEditor dengan instans yang dapat diperbolehkan adalah Class ContohProperties.

using System;
using System.ComponentModel;
using System.ComponentModel.Design ;
using System.Reflection;
using System.Drawing;
using System.Drawing.Design;
using System.Windows.Forms;
using System.Collections;

public class ContohCollectionEditor : CollectionEditor
{
public ContohCollectionEditor(Type type)
: base(type) { }
protected override bool CanSelectMultipleInstances()
{
return false;
}
protected override Type CreateCollectionItemType()
{
return typeof(ContohProperties);
}
protected override Type[] CreateNewItemTypes()
{
Type[] types = new Type[] { typeof(c) };
return types;
}
}
Class : ContohProperties.cs

// Class ini adalah sebuah class property yang tidak boleh di-inherits oleh class lain (sealed) yang isinya terdiri dari property dan private variable.

public sealed class ContohProperties
{
private string _Text;
public string Text
{
get { return _Text; }
set { _Text = value; }
}
public ContohProperties(string text)
{
this._Text = text;
}
}
Class : Test.cs

// Class ini adalah sebuah class control yang mengimplementasikan sebuah CollectionEditor yang telah di-extends menjadi sebuah class ContohCollectionEditor. Di dalam class ini terdapat sebuah property “Items” yang mempunyai tipe variable ArrayList. Kemudian property ini di set attribute-nya “[Editor(typeof(ContohCollectionEditor), typeof(UITypeEditor)), Category("ContohProperty")]” yang artinya adalah bahwa tipe editor yang akan digunakan oleh property ini adalah Class ContohCollectionEditor.

[ParseChildren(true, "Items"), ToolboxData("<{0}:Test runat=server>")]
public class Test : CompositeControl, INamingContainer
{
private string ArrayList _items;
[Editor(typeof(ToolbarButtonCollectionEditor), typeof(UITypeEditor)), Category("ContohProperty")]
public virtual ArrayList Items
{
get
{
if (_items == null) _items = new ArrayList();
return _items;
}
}

protected override void Render(HtmlTextWriter writer)
{
writer.RenderBeginTag(HtmlTextWriterTag.Table);
writer.RenderBeginTag(HtmlTextWriterTag.Tr);

foreach (ContohProperties obj in Items)
{
writer.RenderBeginTag(HtmlTextWriterTag.Td);
writer.Write(obj.Text);
writer.RenderEndTag();// END TD
}

writer.RenderEndTag();// END TR
writer.RenderEndTag();// END TABLE
}
}

Cara penggunaannya adalah :
Buatlah sebuah file Test.aspx lalu kemudian drag Control (Test) dari toolbox, lalu isikanlah Property Items dan masukkanlah Property Text yang ada di Editor Window.

« Newer Posts