PDA

View Full Version : [FIXED] [V0.7] Error when setting text in ToolbarTextItem



Jurke
Nov 27, 2008, 5:39 AM
Hi
Im trying to set the text property of a ToolbarTextItem, but that generates in a runtime javascript error. Please help me whit this quick! I need this to work asap.
Thanks!





<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
txtTest.SetText("TEST");
}

</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 id="Head1" runat="server">
<title>Travel Perfect</title>


<script type="text/javascript">


</script>


</head>
<body>
<form id="form2" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server">
</ext:ScriptManager>







<ext:Panel runat="server" ID="Panel" Border="true" Title="test" BodyStyle="padding:4px;" AutoWidth="true" >
<Body>
<ext:StatusBar
ID="sbBottombar"
runat="server"
DefaultText="">
<Items>

<ext:ToolbarSeparator ID="ToolbarSeparator1" runat="server" />
<ext:ToolbarTextItem runat="server" ID="txtTest"></ext:ToolbarTextItem>
<ext:ToolbarSeparator ID="ToolbarSeparator6" runat="server" />



</Items>
</ext:StatusBar>
</Body>
</ext:Panel>






</form>
</body>
</html>

Vladimir
Nov 27, 2008, 6:41 AM
Hi Mikael,

The SetText is incorrectly implemented. We will fix this.
Please note that SetText must be called only during AjaxEvent. During initial Page_Load you can use Text property.
I wrote small example which shows how to change Text of ToolbarTextItem.



<%@ Page Language="C#" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if(!Ext.IsAjaxRequest)
{
TextItem1.Text = "Some text";
}
}

protected void ChangeText_Click(object sender, AjaxEventArgs e)
{
// 0 - is index of ToolbarTextItem in Toolbar's Item collection
this.ScriptManager2.AddScript("{0}.items.get(0).setText('Changed Text')", Toolbar1.ClientID);
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Example</title>
</head>
<body style="padding:10px;">
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager2" runat="server" StateProvider="PostBack" />


<ext:Panel ID="Panel1" runat="server" Title="Panel with toolbar" Width="600" Height="300">
<TopBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:ToolbarTextItem ID="TextItem1" runat="server"></ext:ToolbarTextItem>

<ext:ToolbarSeparator/>

<ext:ToolbarButton runat="server" Text="Change Text">
<AjaxEvents>
<Click OnEvent="ChangeText_Click"></Click>
</AjaxEvents>
</ext:ToolbarButton>
</Items>
</ext:Toolbar>
</TopBar>
</ext:Panel>
</form>
</body>
</html>

Jurke
Nov 27, 2008, 6:51 AM
Ok, will you notify me when its fixed?

Will my way of setting the textfield result in errors? Because I need to set the value on every page load, ajax request or not. So I thought that was the simplest way to do it.

/Best regards
Mikael

Vladimir
Nov 27, 2008, 7:18 AM
Hi Mikael,

The fix has been committed to the SVN
Please update and retest

Jurke
Nov 27, 2008, 7:45 AM
Thanks you! works great now.