PDA

View Full Version : Blur Listener - setValue on Textfield not working?



Tbaseflug
Jun 28, 2012, 1:57 AM
I have the below - when I attempt to set a textfield via setValue on a listener handler/blur - not working - the textfield is not picking up the array value from th JS - from the split() funtion - txtWordOne is not picking up the value?


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Hospitals_To_Peer_Groups.aspx.cs"
Inherits="PARA_Staff_Only_Projects._Default" Debug="true" %>
<%@ 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>
<style type="text/css">
.txt-bold
{
font-family: verdana;
font-weight: bold;
font-size: 10px;
color: #333333;
}
.txt-normal
{
font-family: verdana;
font-weight: normal;
font-size: 10px;
color: #333333;
}
.txt-normal2 .x-form-field
{
font-family: verdana;
font-weight: normal;
font-size: 10px;
color: #333333;
}
</style>
<script type="text/javascript">
function split() {
var s = "This is a test", a = s.split(' ');
alert(a[0]);
txtWordOne.setValue(a[0]);
//document.write(a1.join(" <br> "));
}
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Default" />
<ext:Hidden runat="server" ID="hdnDB" />
<div style="padding-left: 40px; padding-top: 40px;">
<table border="0" cellpadding="4" cellspacing="0" style="width: 640px;">
<tr>
<td style="width: 100px;">
<div class="txt-bold">
Provider ID:</div>
<ext:TextField ID="txtProvID" runat="server" Width="90" Cls="txt-normal2" />
</td>
<td style="width: 310px;">
<div class="txt-bold">
Full Name:</div>
<ext:TextField ID="txtFullName" runat="server" Width="300" Cls="txt-normal2">
<Listeners>
<Blur Handler="split();" />
</Listeners>
</ext:TextField>
</td>
<td>
<div class="txt-bold">
Zip Code:</div>
<ext:TextField ID="txtZipCode" runat="server" Width="60" Cls="txt-normal2">
<Listeners>
<%--Hacky workaround - but Blur event is not working with Ext.Net's latest build--%>
<Blur Handler="btn.click();" />
</Listeners>
</ext:TextField>
</td>
<td valign="top" style="width: 110px;">
<div class="txt-bold" style="padding-bottom: 4px;">
City:</div>
<ext:Label Cls="txt-normal" runat="server" ID="lblCity" />
</td>
<td valign="top">
<div class="txt-bold" style="padding-bottom: 4px;">
State:</div>
<ext:Label Cls="txt-normal" runat="server" ID="lblState" />
</td>
</tr>
</table>
<div>
&nbsp;</div>
<table border="0" cellpadding="4" cellspacing="0" style="width: 400px;">
<tr>
<td>
<div class="txt-bold">
Word 1:</div>
<ext:TextField ID="txtWordOne" runat="server" Width="90" Cls="txt-normal2" />
</td>
<td>
<div class="txt-bold">
Word 2:</div>
<ext:TextField ID="txtWordTwo" runat="server" Width="90" Cls="txt-normal2" />
</td>
<td>
<div class="txt-bold">
Word 3:</div>
<ext:TextField ID="txtWordThree" runat="server" Width="90" Cls="txt-normal2" />
</td>
<td>
<div class="txt-bold">
Word 4:</div>
<ext:TextField ID="txtWordFour" runat="server" Width="90" Cls="txt-normal2" />
</td>
</tr>
</table>
<ext:Button runat="server" ID="btn" Hidden="true">
<DirectEvents>
<Click OnEvent="getCityAndSateByZip" Delay="200" />
</DirectEvents>
</ext:Button>
<br />
</div>
</form>
</body>
</html>

geoffrey.mcgill
Jun 28, 2012, 5:24 AM
Hi,

For me the work 'this' is in the alert when the "Full Name" field is blurred.

Please post a simplified sample we can test with that reproduces the problem. There seems to be a lot of unrelated code in your original sample.

Tbaseflug
Jun 28, 2012, 2:07 PM
That is the strange thing - the alert fires - but the textfield value never gets sets - and does not throw any errors

geoffrey.mcgill
Jun 29, 2012, 12:28 AM
That is the strange thing - the alert fires - but the textfield value never gets sets - and does not throw any errors

For me the string "This" is set on the "Word 1" TextField.

healingnations
Jul 01, 2012, 4:04 AM
That is the strange thing - the alert fires - but the textfield value never gets sets - and does not throw any errors

Try putting the variable 'a' on a separate line and access the first element of the array directly. Sounds weird but I've seen this problem before.
If that doesn't work then try putting a hard coded value in the setValue method to make sure it's not something else. Also, how do you know for sure
there are no errors, I don't see a try catch block in your javascript function?


try
{
var a = s.split(' ')[0];
txtWordOne.setValue(a);

//txtWordOne.setValue('just a hardcoded test');
}
catch (err)
{
alert(err);
}