如何添加动态文本框的HTML输入的地方 [英] How to add dynamic textbox in the place of html input
本文介绍了如何添加动态文本框的HTML输入的地方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不得不以字符串格式生成一个表,并在体内
加入 字符串中间=< TR类='cart_item'>中+< TD类=产品删除>中+
<'?handler.ashx ID = + ID + A HREF ='级=删除标题=删除此项目>&安培;倍;< / A>中+
&所述; / TD>中+
< TD类='产品缩略图>中+
&所述; A HREF ='StoreDetails.aspx的id =?+ ID +'>中+
< IMG SRC ='+拇指+'+
类='依恋shop_thumbnail WP-后映像ALT =+ PNAME +/>< / A>< / TD>中+
< TD类=产品名称>中+
&所述; A HREF =?StoreDetails.aspx的id =+ ID +'>中+ pname中+&所述; / a取代;&所述; / TD>中+
< TD类=产品价格>中+
<跨度类='量'><我类='图标INR'>< / I>+ cd.packsize +< / SPAN>< / TD>中+
< TD类=产品价格>中+
<跨度类='量'><我类='图标INR'>< / I>+价格+< / SPAN>< / TD>中+
< TD类='产品数量'>中+
< DIV CLASS ='数量buttons_added'><输入值=' - '级='减'的类型='按钮'>中+
<输入步骤='1'分='1'的名字=数量值='+数量+标题='数量'级=输入文字数量文本'ID ='txtqty+ CD。 ID +大小=4型=文本>中+
先在这里,我已经添加了输入 TYPE =文本
在HTML中,但现在我想补充asp.net文本框控件
<输入值='+'级='加'类型='按钮'>< / DIV>中+
//数量+
&所述; / TD>中+
&所述; TD类='产物的小计'>中+
<跨度类='量'><我类='图标INR'>< / I>+(Convert.ToDouble(价)*数量)+< / SPAN>< / TD>中+
&所述; / TR>中;
// INT数量=((词典< INT,INT>)会议[购物车])[ID]
cartInfo.InnerHtml + =中间;
解决方案
取要绘制表占位符的控制。
在你的ASPX文件:
< ASP:占位符ID =PH=服务器/>
在后面ASPX.CS文件code:
文字loLit1 =新的文字();
loLit1.Text =字符串的数量文本框上面的;
ph.Controls.Add(loLit1);
文本框loTxt =新文本框();
loTxt.Attributes.Add(步骤,1);
loTxt.Attributes.Add(最小,1);
loTxt.Attributes.Add(名,量);
loTxt.Text =10;
loTxt.ToolTip =数量;
loTxt.ID =txtqty;
ph.Controls.Add(loTxt);
文字loLit2 =新的文字();
loLit2.Text =字符串的数量文本框后;
ph.Controls.Add(loLit2);
I had generate a table in a string format and added in the body
string mid = "<tr class='cart_item'>" + "<td class='product-remove'>" +
" <a href='handler.ashx?id=" + id + "' class='remove' title='Remove this item'>×</a>" +
"</td>" +
" <td class='product-thumbnail'>" +
" <a href='StoreDetails.aspx?id=" + id + "'>" +
"<img src='" + thumb + "' " +
"class='attachment-shop_thumbnail wp-post-image' alt='" + pname + "' /></a> </td>" +
" <td class='product-name'>" +
" <a href='StoreDetails.aspx?id=" + id + "'>"+pname+"</a> </td>" +
" <td class='product-price'>" +
" <span class='amount'><i class='icon-inr'></i> " + cd.packsize + "</span> </td>" +
" <td class='product-price'>" +
" <span class='amount'><i class='icon-inr'></i> " + price + "</span> </td>" +
" <td class='product-quantity'>" +
" <div class='quantity buttons_added'><input value='-' class='minus' type='button'>" +
"<input step='1' min='1' name='quantity' value='" + qty + "' title='Qty' class='input-text qty text ' id='txtqty" + cd.id+"' size='4' type='text'>" +
first here, I have added the input type="text"
in html, but now I want to add asp.net textbox control
"<input value='+' class='plus' type='button'></div>" +
// qty +
"</td>" +
"<td class='product-subtotal'>" +
" <span class='amount'><i class='icon-inr'></i> " + (Convert.ToDouble(price) * qty) + "</span> </td>" +
"</tr>";
// int qty = ((Dictionary<int, int>)Session["cart"])[id];
cartInfo.InnerHtml += mid;
解决方案
Take a PlaceHolder control where you want to render table.
In your ASPX file:
<asp:PlaceHolder ID="ph" runat="server" />
In code behind ASPX.CS file:
Literal loLit1 = new Literal();
loLit1.Text = "String above the Quantity Textbox";
ph.Controls.Add(loLit1);
TextBox loTxt = new TextBox();
loTxt.Attributes.Add("step", "1");
loTxt.Attributes.Add("min", "1");
loTxt.Attributes.Add("name", "quantity");
loTxt.Text = "10";
loTxt.ToolTip = "Qty";
loTxt.ID = "txtqty";
ph.Controls.Add(loTxt);
Literal loLit2 = new Literal();
loLit2.Text = "String After the Quantity Textbox";
ph.Controls.Add(loLit2);
这篇关于如何添加动态文本框的HTML输入的地方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文