How to take an input value and manipulate in Behind

Asked

Viewed 1,137 times

0

Guys with a difficulty where I need to take the value of a text input and manipulate it in the aspx page’s Cs. I am using repeater to add the data to the table, but while trying to pull the input data I am not succeeding...

aspx.:

 <input type="text" id="dinheiro" name="dinheiro" /> 

page.aspx.Cs:

namespace GerencialWeb
{
    public partial class ReceitasPeriodicas : System.Web.UI.Page
    {

        public class Fluxo
        {
            public DateTime data { get; set; }
            public double valor { get; set; }

        }

        protected void Page_Load(object sender, EventArgs e)
        {

            double valort = Request["dinheiro"];


            List<Fluxo> ListaFluxo = new List<Fluxo>();            
            ListaFluxo.Add(new Fluxo() { valor = variavel do request  ,data = DateTime.Now });




            this.rptFluxo.DataSource = ListaFluxo;
            this.rptFluxo.DataBind();


        }        
    }
}

Note: The value that enters the input has a function that transforms it into value (Currency): A js Mask. (Even the pure value without Mask, has already been tested and also unsuccessful.). someone has some idea of what to do?

  • put what you did on the page!

  • I edited the . Cs page there!

1 answer

1


I think you just need to put one runat="server" in its input:

<input type="text" id="dinheiro" name="dinheiro" runat="server"/>

And so, you can get the content of the control here:

string myStringFromTheInput = dinheiro.Value;

And so on:

public partial class ReceitasPeriodicas : System.Web.UI.Page
{
    public class Fluxo
    {
        public DateTime data { get; set; }
        public double valor { get; set; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {

        string myStringFromTheInput = dinheiro.Value;
        double valort = double.Parse(myStringFromTheInput);

        List<Fluxo> ListaFluxo = new List<Fluxo>();            
        ListaFluxo.Add(new Fluxo() { valor = valort, data = DateTime.Now });

        this.rptFluxo.DataSource = ListaFluxo;
        this.rptFluxo.DataBind();
    }        
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.