how to post a texbox entered value into method
and store data
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sanjeeb LenkaPosted Dec 3, 2013, 6:43 AM
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);
}
}
muthukumarPosted Dec 3, 2013, 6:13 AM
Sanjeeb LenkaPosted Dec 2, 2013, 3:37 AM