Saturday, 13 September 2014

How to Create Dynamic TextBox And Get Its Value

Before i was explain How to create dynamic Asp controls.How to Generate Dynamic Asp ControlsNow Here i will show to you how to retrieving the value of the dynamically created Text Box In Asp.Net. 



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ashokdemo
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            TextBox new_textbox = new TextBox();
            new_textbox.ID = "txt" + 1;
            new_textbox.Text = "";
            PlaceHolder1.Controls.Add(new_textbox);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string OptionID = "txt" + 1;
            TextBox tb = (TextBox)PlaceHolder1.FindControl(OptionID);
            Response.Write(tb.Text);
    
                  }}}}
                      
    

0 comments::

Post a Comment

Copyright © DotNet-Ashok