0
votes

I know there's a lot of information on this, but mine doesn't seem to be working out so well. I have a form that's created in C# in a form panel. My textfields are created like below:

Ext.Net.Panel panel = new Ext.Net.Panel();
Field field = null;
field = new TextField();
field.Name = "FieldTitle";
field.ID = "FieldID";
panel.Add(field);
this.searchform.Add(panel);
this.searchform.Add(new Ext.Net.Button()
{
Text = "Search",
Handler = "getID();"
});

When the search button is hit, then a JavaScript function is called which performs a store reload:

Ext.getCmp("#Gridpanel").getStore().reload({});

On the reload, I want to read the form fields and use the text for another part of the code. However, the below code doesn't seem to be working:

if(X.isAjaxRequest){
var ctrl = X.GetCmp<TextField>("FieldID");
string value = ctrl.Value.ToString();
}

I can get inside the 'if' statement, but ctrl comes back as null. Is there something else I need to include to grab the text field data?

EDIT

So I'm realizing that I'll have to pass an array of the search field ID's to a JavaScript function, then send a dataset back to the server side in order to implement the search. Just to throw it out there, is there a way to dynamically create controls (ie; a TextField) in C# and then get the value from those controls after an event is fired (ie; a button click)?

1

1 Answers

0
votes

You can try to get the textfield using Ext.getCmp("#FieldID") or X.getCmp("#FieldID"). FieldID is the client ID for TextField.

Use developer Tools to check the ID for the TextField