?
Solved

asp.net / c# / usercontrol

Posted on 2011-10-06
2
Medium Priority
?
173 Views
Last Modified: 2012-05-12
  LblItem.Text = LblItem.Text + "<input type=text name=" + "TxtItem_" + i + " class=TextBoxBgColor id=" + "TxtItem_" + i + " value=" + Request.Form["TxtItem_" + i.ToString()] + "><br />";

Instead of <input....>
I prefer using asp server input control like <asp:textbox>...</asp:textbox>

1. How can I do  that?
2. How can i code a way to tab horizontally?
now it is tabbed vertically.

Thanks

             
int TotalCount = int.Parse(Ddl_TotalItem.SelectedValue);
            for (int i = 0; i < TotalCount; i++)
            {
                LblItem.Text = LblItem.Text + "<input type=text name=" + "TxtItem_" + i + " class=TextBoxBgColor id=" + "TxtItem_" + i + " value=" + Request.Form["TxtItem_" + i.ToString()] + "><br />";
                LblDescription.Text = LblDescription.Text + "<input class=TextBoxBgColor name=" + "TxtDescription_" + i + " id=" + "TxtDescription_" + i + "><br />";
                LblTotalUnit.Text = LblTotalUnit.Text + "<input class=TextBoxBgColor name=" + "TxtTotalUnit_" + i + " id=" + "TxtTotalUnit_" + i + "><br />";
                LblUnitMeasure.Text = LblUnitMeasure.Text + "<input class=TextBoxBgColor name=" + "TxtUnitMeasure_" + i + " id=" + "TxtUnitMeasure_" + i + "><br />";
                LblQuantity.Text = LblQuantity.Text + "<input class=TextBoxBgColor name=" + "TxtQuantity_" + i + " id=" + " id=" + "TxtQuantity_" + i + "><br />";
                LblUnitPrice.Text = LblUnitPrice.Text + "<input class=TextBoxBgColor name=" + "TxtUnitPrice_" + i + " id=" + "TxtUnitPrice_" + i + "><br />";
                LblAmount.Text = LblAmount.Text + "<input class=TextBoxBgColor name=" + "TxtAmount_" + i + " id=" + " id=" + "TxtAmount_" + i + "><br />";
            }

Open in new window

0
Comment
Question by:Webboy2008
2 Comments
 
LVL 16

Accepted Solution

by:
Easwaran Paramasivam earned 2000 total points
ID: 36928712
It is better to use HTML contrl when asp.net control is non-mandatory. If still you want to add ASP.NET control follow below way.

Generate asp:Textbox dynamically and append its text to your label.

Say for example:

TextBox txt1= new TextBox();
txt1.id="YourID";
txt1.Text =  Request.Form["TxtItem_" + i.ToString()]
Page.Controls.Add(txt1);

Then in your label

LblItem.Text = LblItem.Text +  txt1.Text;

Refer:
http://ganeshmohan.wordpress.com/aspnet-and-c-generate-html-controls-dynamically/
http://msdn.microsoft.com/en-us/library/kyt0fzt1.aspx
http://www.4guysfromrolla.com/articles/082102-1.aspx

0
 

Author Comment

by:Webboy2008
ID: 36931650
but i need "<br>" at the end of every control.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month14 days, 15 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question