ITPub博客

首页 > IT职业 > IT生活 > 动态产生一个TextBox,并使输入的文本靠右对齐

动态产生一个TextBox,并使输入的文本靠右对齐

IT生活 作者:galebird 时间:2021-09-09 09:45:03 0 删除 编辑

动态产生一个TextBox控件,还要在这个文本框输入的文本是靠右对齐。 

图片描述 protected void Page_Load(object sender, EventArgs e)
    {
       //new一个TextBox
        TextBox textBox = new TextBox();
        //添加样式,靠右对齐
        textBox.Attributes.CssStyle.Add("text-align", "right");
        //把TextBox加入至form中去
        this.form1.Controls.Add(textBox);           
    }图片描述

 

网页在run的效果:

图片描述

 

ViewSource,可以看到它产生的html,20行:

View Code  1 html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 
 3 
 4 

<br> 5 <br> 6 
 7 
 8     

 9 

10 
11 

12 
13 

14 
15     
16 

17     

18     
19     

20     

21 
22 

 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1331/viewspace-2806884/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: T-SQL HAVING
请登录后发表评论 登录
全部评论

注册时间:2019-04-15

  • 博文量
    92
  • 访问量
    577