PDA

View Full Version : Textfield problem



unaltro2
Jan 29, 2010, 11:56 AM
Hi everyone,

i'm having some troubles with the textfield control:

1) when a page load event is fired, some textfield controls are loaded (with the values obtained from the database)
through the Text Property of each one

2) after i change manually the value inside a textfield control

3) after this, through the 'Text' or' Value' properties, i can obtain only the first value (that one obtained previously from the database) and not the new one that i have just written.

Please, can anyone of you help me?

Thanks.

Here some markup code:


<ext:Anchor>
<ext:Label ID="Label2" runat="server" X="0" Y="42" Text="Cognome:" />
</ext:Anchor>
<ext:Anchor>
<ext:TextField ID="txtSurname" runat="server" X="105" Y="37" Width="200px" MaxLength ="50"/>
</ext:Anchor>
<ext:Anchor>
<ext:Label ID="Label12" runat="server" X="330" Y="42" Text="Nome:" />
</ext:Anchor>
<ext:Anchor>
<ext:TextField ID="txtName" runat="server" X="370" Y="37" Width="200px" MaxLength ="50"/>
</ext:Anchor>

geoffrey.mcgill
Jan 29, 2010, 12:52 PM
Hi unaltro2,

Can you post a full .aspx sample demonstrating the complete scenario? Your markup looks fine, but that only tells half the story.

unaltro2
Jan 29, 2010, 1:07 PM
Hi,

on Page_Load event


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
...
some code to retrieve the "varName" value from the database, and then, for each textfield control:
....

txtName.text = varName

...
and so on...
...
End Sub

after this, I change manually the value in the textfield control "txtName" and, from the server-side sub "UpdateAnaImp", I try to retrieve with no success the new value (just writed by myself).

the server-side sub is called from:


<ext:ToolbarButton ID="ToolbarButton_AggiornaAnaImp" runat="server" Text="Aggiorna" Icon="Disk">
<AjaxEvents>
<Click OnEvent="update_AnaImp" />
</AjaxEvents>
</ext:ToolbarButton>

and it is like this:


Protected Sub update_AnaImp()
Select Case txtName.Text <----------------- heres it's the old value !
Case ....
Case ....
end Select
End sub

Thanks.

geoffrey.mcgill
Jan 29, 2010, 1:13 PM
I think the problem is you are resetting the .Text value upon each Page_Load. When the AjaxEvent is fired, the Page_Load is going to fired as well.

You need to wrap your initial Page_Load logic in an !Ext.IsAjaxRequest.


Example



if (!Ext.IsAjaxRequest) { // do something }


Hope this helps

unaltro2
Jan 29, 2010, 1:24 PM
Ok, i have made what you have said, and now it's all perfectly working.

Thank you very much.