Cannot get current value from components fetched via this.GetCmp<Textfield>()

  1. #1

    Cannot get current value from components fetched via this.GetCmp<Textfield>()

    Hi Geoffrey & all Support:

    User have a further question, at the server side in index.cshtml.cs file.
    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.
    Becuase from my code I need to check the button status and process next code logic.

    Could Ext.net Support handle above questions ?
    Thank you very much again.
  2. #2
    Hello Mr. Huang!

    I will try to help you on this issue from now on.

    Quote 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 use GetCmp<>(). 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 this.GetCmp<Button>().

    The GetCmp 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 fieldID 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!

    EDIT: As the subject seems to have shifted from the initial thread's question, I went ahead and moved your post to a new thread.
    Last edited by fabricio.murta; May 24, 2023 at 1:52 AM.
  3. #3
    Hi Fabricio:

    1. Appreciate for your professional & specific reply sincerely.
    It's really large helpful for user.

    Appreciate for your professional & specific reply sincerely.
    It's really large helpful for user.
    I already relay the messages back to user.

    2. User- LIOU,ZE-SIAN, already registered the Ext.NET forums, account name: richardliu

    Could you please help to upgraded user’s account name: richardliu, to a Premium member and he could provide reply in my posts and create new posts in the Premium Help forums ?


    Thank you for your support very much.
  4. #4
    The richardliu account has been upgraded to a Premium member. Welcome richardliu.
    Geoffrey McGill
    Founder

Similar Threads

  1. this.getCmp<T> issue
    By VADIM in forum 7.x Classic Help
    Replies: 1
    Last Post: Mar 31, 2021, 7:59 PM
  2. Ext.getCmp is not working
    By ksaadain in forum 4.x Help
    Replies: 0
    Last Post: Nov 07, 2017, 12:45 PM
  3. Replies: 1
    Last Post: May 18, 2016, 5:45 AM
  4. [CLOSED] App vrs getCmp
    By Z in forum 3.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 10, 2015, 9:16 PM
  5. X.GetCmp and FileUploadField
    By josecano in forum 1.x Help
    Replies: 2
    Last Post: May 01, 2013, 7:56 AM

Posting Permissions