PDA

View Full Version : [CLOSED] TextField.FieldLabel is not changed in Code Behind



supera
Jan 24, 2012, 1:00 PM
Hi!

I need change the FieldLabel of my TextField in Code Behind, but when I set the property FieldLabel, the FieldLabel not changed...

This works fine in 1.x version...

Am I doing something wrong? changed the way to change this property? No reference found in the ChangeLog...

I create a aspx to demostrate this problem...



<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Teste3.aspx.vb" Inherits="SuperaWeb.Teste3" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
Protected Sub btn1_click(sender As Object, e As Ext.Net.DirectEventArgs)
txtNome.FieldLabel = "Label 01"
dsMessage.Text = "FieldLabel changed to 'Label 01'"
End Sub

Protected Sub btn2_click(sender As Object, e As Ext.Net.DirectEventArgs)
txtNome.FieldLabel = "Label 02"
dsMessage.Text = "FieldLabel changed to 'Label 02'"
End Sub

</script>

<!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>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:TextField runat="server" ID="txtNome" FieldLabel="Label 01" Text="" />
<ext:DisplayField runat="server" ID="dsMessage" Text="" Width="300px"/>
<ext:Button runat="server" ID="btn1" Text="change FieldLabel to 'Label 01'">
<DirectEvents>
<Click OnEvent="btn1_click"/>
</DirectEvents>
</ext:Button>
<ext:Button runat="server" ID="btn2" Text="change FieldLabel to 'Label 02'">
<DirectEvents>
<Click OnEvent="btn2_click"/>
</DirectEvents>
</ext:Button>
</form>
</body>
</html>


Thanks for any help

Daniil
Jan 24, 2012, 2:51 PM
Hi,

Confirmed. Thanks for the report.

The fix has been added to SVN and will appear in DP2.

For now, please use:

TextField1.Call("setFieldLabel", "Label 02")

supera
Jan 24, 2012, 3:47 PM
Hi Daniil... thanks for your response...

I try follow your suggestion, but errors occurs...
In the messagebox, in attached image, is written:

"runtime error in Microsoft JScript: the object does not support property or method 'setFieldLabel'

3759

Daniil
Jan 24, 2012, 4:16 PM
Confirmed. This method has appeared in the ExtJS 4.1.0, but DP1 is based on ExtJS 4.0.7.

Please try to add the following thing into a page's <head>, should work.

Example

<ext:ResourcePlaceHolder runat="server" Mode="ScriptFiles" />

<script type="text/javascript">
Ext.form.field.Base.override({
setFieldLabel: function(label){
label = label || '';

var me = this,
separator = me.labelSeparator,
labelEl = me.labelEl,
last;

me.fieldLabel = label;
if (me.rendered) {
if (Ext.isEmpty(label) && me.hideEmptyLabel) {
Ext.destroy(me.labelEl);
me.labelEl = null;
} else {
labelEl = me.createLabelEl();
last = label.substr(label.length - 1);

if (last != separator) {
label += separator;
}
labelEl.update(label);
}
me.doComponentLayout();
}
},

createLabelEl: function(){
var me = this;

if (!me.labelEl) {
me.labelEl = me.el.insertFirst({
tag: 'label',
htmlFor: me.getInputId(),
cls: me.getLabelCls(),
style: me.getLabelStyle()
});
}
return me.labelEl;
}
});
</script>

supera
Jan 24, 2012, 4:28 PM
Hi Daniil

Works

Thanks a lot