PDA

View Full Version : [CLOSED] extending textfield



metci
Jul 01, 2014, 1:13 PM
Hi,

To capitalize text entered by user, i want to extend textfield and create another control, BSTextField. Below there are two usage samples, it's working fine when the control is not in any ext.net container and it's shown as horizantal bar when it's in ext.net container like panel (At least the only difference I could notice is this).

Can you help me about this problem?
Regards.



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ext.Net
{
public class BSTextField : TextField
{
protected override void OnInit(EventArgs e)
{
Listeners.Change.Handler = "newValue = newValue.replace(/\\i/g, 'İ');this.setValue(newValue.toUpperCase());";
base.OnInit(e);
}

public override string InstanceOf
{
get
{
return "Ext.form.field.Text";
}
}

public override string XType
{
get
{
return "bstextfield";
}
}

public override string Text
{
get
{
return base.Text.ToUpper();
}
set
{
base.Text = value.ToUpper();
}
}

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
}

protected override void OnDataBinding(EventArgs e)
{
base.OnDataBinding(e);
}
}
}


Control working fine:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<form id="form1" runat="server">
<div>
<ext:BSTextField ID="txt2" runat="server" />
</div>
</form>
</body>
</html>


Control shown as a horizontal bar:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<form id="form1" runat="server">
<div>
<ext:Panel runat="server">
<Items>
<ext:BSTextField ID="txt2" runat="server" />
</Items>
</ext:Panel>
</div>
</form>
</body>
</html>

Daniil
Jul 01, 2014, 2:35 PM
Hi @metci,

Please remove overrides of the InstanceOf and XType properties. They should be overridden only if you implement another JavaScript class for the custom control.

metci
Jul 02, 2014, 7:30 AM
It works, thank you.