PDA

View Full Version : [CLOSED] Change textfield values from client side



zwf
Oct 19, 2012, 2:59 PM
Hi,

following case:

3 textfields.
User enters a value in one, the two other textfields need to change to the same value ....
and/or change to a value from a controller ......

This is very important to my client......

Regards,
Holger

geoffrey.mcgill
Oct 19, 2012, 3:47 PM
This is very basic functionality of the library. You can use the .setValue() function.

Example


App.TextField2.setValue(App.TextField1.getValue()) ;

zwf
Oct 19, 2012, 4:41 PM
This is very basic functionality of the library. You can use the .setValue() function.

Example


App.TextField2.setValue(App.TextField1.getValue()) ;

Yeah, thanks.
I did it with javascript


function setBeifahrerEqual() {
var txt_ES_PS_S3_S4_BEI = Ext.getCmp('txt_ES_PS_S3_S4_BEI').getValue();
Ext.getCmp('txt_ES_PS_S7_S8_BEI').setValue(txt_ES_ PS_S3_S4_BEI);
Ext.getCmp('txt_ES_PS_S1_S3_BEI').setValue(txt_ES_ PS_S3_S4_BEI);

}

and called it from the listener.

But what about the second case ?
I want to do that with values or a value from a MVC controller ???

Regards,
Holger

Daniil
Oct 19, 2012, 5:30 PM
Hi Holger,

To change a value of the TextField from a controller action you can use this code.

var field = X.GetCmp<TextField>("TextFieldId");
field.Text = "new text";
return this.Direct();

Or just return a text from a controller action to apply manually on client within a Success handler.

zwf
Oct 22, 2012, 9:18 AM
Hi Holger,

To change a value of the TextField from a controller action you can use this code.

var field = X.GetCmp<TextField>("TextFieldId");
field.Text = "new text";
return this.Direct();

Or just return a text from a controller action to apply manually on client within a Success handler.

Do you have some sample code ? In razor ;?

Regards,
Holger

Daniil
Oct 22, 2012, 10:25 AM
Here you are.

Example View

<!DOCTYPE html>

<html>
<head>
<title>Ext.Net.MVC v2 Example</title>
</head>
<body>
@Html.X().ResourceManager()

@(Html.X().TextField().ID("TextField1"))

@(Html.X().Button().Text("Set using X.GetCmp<>").DirectClickAction("SetValue"))

@(Html.X().Button().Text("Set with a Success handler")
.DirectEvents(ds =>
{
ds.Click.Url = Url.Action("GetText");
ds.Click.Success = "App.TextField1.setValue(result.value);";
})
)
</body>
</html>



Example Controller

using System.Web.Mvc;
using Ext.Net;
using Ext.Net.MVC;

namespace Work2MVC.Controllers
{
public class RazorController : Controller
{

public ActionResult Index()
{
return View();
}

public ActionResult SetValue()
{
var field = X.GetCmp<TextField>("TextField1");
field.Text = "new text 1";
return this.Direct();
}

public ActionResult GetText()
{
return this.Json(new { value = "new text 2" }, JsonRequestBehavior.AllowGet);
}
}
}

zwf
Oct 22, 2012, 11:06 AM
Yeah,
here we are !
Thanks again.
Regards,
Holger