English 中文(简体)
• 如何将投入类型=“序号”放在动态文本箱中,编号为“编号”。
原标题:How to set input type="number" on dynamic textbox in c# codebehind

我在C#/ASP中建立了动态的版本Box。 互联网网页,我想适应移动浏览器:

TextBox qtybox = new TextBox();  
qtybox.ID="qtybox";   
qtybox.Text = "0";  
qtybox.Width = 30;   
container.Controls.Add(qtybox);

I see that I can directly set this in a plain HTML <form>:

<input type="number">

......之后,将建立数字键盘。

我怎么能用我手法中充满活力的文本Box来做,或者我能做吗?

是否有另一种办法,在我网页上积极控制手法中的数字输入,这样会更好吗? 我是否需要利用 Java在控制之后的“打”字? (如果可能,则有网路。)

最佳回答

我从记忆中写这段话,但我认为是:

qtybox.Attributes.Add("type", "number");
问题回答

可以通过海关控制做到这一点。 页: 1

namespace CustomTextBoxControls
{
    public class TextBoxWithType : TextBox
    {
        public string modifyType { get; set; }

        protected override void Render(System.Web.UI.HtmlTextWriter output)
        {
            if (!string.IsNullOrEmpty(modifyType))
            {
                output.AddAttribute("type", modifyType);
            }

            base.Render(output);
        }
    }
}

登记页。

<%@ Register Namespace="CustomTextBoxControls" TagPrefix="CustomControl" Assembly="CustomTextBoxControls" %>

<CustomControl:MaskedTextBoxWithType id="txtNumber" modifyType="number" runat="server"></CustomControl:MaskedTextBoxWithType>

属性将从上述改性财产中扣除。 因此,这也可以是货币,也可以是具有超文本5支持的任何其他类型。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签