C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

Need textboxes again and again on clicking 'addbutton'


Posted Date: 26 Jun 2009      Posted By: Reddy      Member Level: Gold     Points: 1   Responses: 4



hi friends,


On the pageload i will get TextBox1,TextBox2,'Addbutton' and 'Savebutton'


on clicking 'Addbutton' i need to store these two textbox values on separate variables and get two textboxes again.

This will be repeating as many times as he/she click on 'Addbutton'

finally all the textbox values store on the database on clicking save button.

how would i achieve it. please help me..

Thanks in advance
reddy.sankar1983@gmail.com






Responses

Author: Anil Chalasani    26 Jun 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

in your Addbutton click event

add two text boxes to the form

Thanks & Regards
Anil Chalasani.



Author: Anil Kumar Pandey    26 Jun 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

hi,

you need to create the control dynamically try the following code for that.


protected void Page_Load(object sender, EventArgs e)
{
LinkButton lnk = new LinkButton();
lnk.ID = "lnk" + 1;
lnk.Text = "more1";
lnk.Click += new EventHandler(LinkButton3_Click);
form1.Controls.Add(lnk);
}

protected void LinkButton3_Click(object sender, EventArgs e)
{
Response.Write("Link Button Clicked");
}


Thanks & Regards
Anil Kumar Pandey



Author: Robin Thomas    26 Jun 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Creating dynamic controls is easy. but you need to be careful while retrieving the values of dynamically created controls.

You can refer the following post.

http://www.aspsnippets.com/post/2009/06/11/Creating-Dynamic-DropDownList-Controls-in-ASPNet.aspx

Robin Thomas
Freelancer
visit for fresher jobs



Author: Alka    26 Jun 2009Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

Create textbox dynamically:

TextBox textbox = new TextBox();
textbox.ID = "textbox" + 1;
textbox.Text = "Dynamic TextBox";
this.form1.Controls.Add(textbox);



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : How to create dynamic images on button click..
Previous : How to change number format ?
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use