Why does my save use the initial value of my TextBox and not the entered value?

前端 未结 6 1438
遥遥无期
遥遥无期 2021-01-01 16:19

I have a textbox on my website:


On page l

6条回答
  •  粉色の甜心
    2021-01-01 16:52

    This is because the Page_Load event happens before your method setCoordinates is called. This mean that the Latitude.Text value is the same as before.

    You should change the load function so it does not always set the initial value of the textbox.

    By changing the page_load event with !Page.IsPostBack, the only time the initial value is given, is the first time the page originaly loads.

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack) 
        {
            Latitude.Text = thisPlace.Latitude;
        }
    }
    

提交回复
热议问题