Hello Mr. Huang!
I will try to help you on this issue from now on.
Originally Posted by JohnsonHuang
I only can use this.GetCmp<TextField>("fieldID").setValue("test") , but can not get value from this.GetCmp<TextField>("fieldID").Value, also when I need to get the hidden status from a button , I can not get the current hidden status.
That's correct... except you can't only
. We'll get to this later. For the correct part, this happens because GetCmp
makes an indirect reference to the component. Ext.NET can't tell at server side how exactly is the state of the page. This would require passing the full page state in every client-server request and make the data communication potentially very slow.
If you know your code-behind procedure is going to need a given aspect of a "live" component, however it is at the time the server process is called, you need to explicitly pass it. Optimally, you'll only forward component state/values of what your server code needs to handle.
The following examples shows some ways to pass specific client-side component values, and their own statuses (like, the whole component with its current status filled):
- Layout > Form Layout > Login
- Grid Panel > Array Grid > DirectEvent Creation
The first example shows most simple manner to pass form values while avoiding to pass data that's never going to be used, like the form fields hidden or disabled states, etc; it simply passes the actual values used to validate the simulated login process.
The second one, while the button is clicked to create the grid, also passes the whole button state, so that it's state and properties are accessible by the controller code without the need of
approach, again, is best suited if the current component settings are not relevant to the controller, and it just needs to pass new settings back. It avoids passing in the whole components -- or even parts of it, if they're not going to be used, saving that bit of bandwidth on every request.
Hope this helps clarifying the issues. If it's still not clear how the
text field current value could be fetched from controller code, please provide a simplified test case we could run and tell exactly why it's not working and what to do to fix it.
Looking forward to your follow-up!
As the subject seems to have shifted from the initial thread's question
, I went ahead and moved your post to a new thread.