Form field values don't get new values

  1. #1

    Form field values don't get new values

    Hello, I have the following code:
    protected void Page_Load(object sender, EventArgs e)
            {
                 DashboardExpedicao dashAtual = NGDashboardExpedicao.BuscaDash(id_unidade, DateTime.Now);
    
                    formMetas.SetValues(new
                    {
                        metaCaminhoes = dashAtual.meta_caminhao,
                        metaTons = dashAtual.meta_ton,
                        atualCaminhoes = dashAtual.caminhao
                    });
                }
            }
    
     protected void AtualizaMetas(object sender, DirectEventArgs e)
            {
                    if (NGDashboardExpedicao.AtualizaMetas(Convert.ToInt32(metaCaminhoes.Number), metaTons.Number,     Convert.ToInt32(atualCaminhoes.Number), id_unidade, DateTime.Now))
                    {
                        X.Msg.Alert("Sucesso!","Metas atualizadas.").Show();
                    }
                    else
                    {
                        X.Msg.Alert("Erro!", "Erro ao atualizar metas.").Show();
                    }
    }
    AtualizaMetas is the DirectEvent called when I submit form. But the value of the fields are still those that I set in page load

    Why it happen?
  2. #2
    Hi @Rtrojack,

    Please try wrapping the Page_Load code into a condition to avoid its execution during a DirectEvent.
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!X.IsAjaxRequest)
        {
            // Your code
        }
    }

Similar Threads

  1. Replies: 10
    Last Post: Sep 20, 2017, 2:31 AM
  2. Replies: 2
    Last Post: May 26, 2015, 1:44 PM
  3. Replies: 0
    Last Post: Nov 06, 2014, 2:49 PM
  4. Replies: 9
    Last Post: Mar 13, 2014, 3:30 PM
  5. AjaxMethod and Field Values
    By idtny in forum 1.x Help
    Replies: 3
    Last Post: Feb 23, 2009, 10:35 PM

Tags for this Thread

Posting Permissions