how to post a texbox entered value into method
and store data
Method
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Dec 3, 2013, 1:43 AM EST
in aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
in .cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public int Age(DateTime dt)
{
DateTime today = DateTime.Today;
int age = today.Year - dt.Year;
if (dt > today.AddYears(-age))
age--;
return age;
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
int age = Age(Convert.ToDateTime(TextBox1.Text));
Response.Write("Age:"+age);
}
}
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Dec 1, 2013, 10:37 PM EST
muthukumar146 reputationPosted Dec 3, 2013, 1:13 AM EST