zoukankan      html  css  js  c++  java
  • Asp.net中, Javascript 操作textBox的属性应用()

    If a control is disabled it cannot be edited and its content is excluded when the form is submitted.If a control is readonly it cannot be edited, but its content (if any) is still included with the submission. 

    即: 当ReadOnly=True时,控件ID在前后天仍可以被查询到。而当Diabled=True, 或者当Visible=True时,一旦Form被前台递交,其ID将不再被前台识别;此时,TextBox空间和Label空间功能将相差无几。

    实际代码中,由于Label控件的局限性,很多时候借用TextBox控件,但显示时何Label一样。如下代码

     <asp:Textbox ID="lblComment"  runat="server" Width="200" ReadOnly="true"  Visible="True" BorderWidth="0px" BorderStyle="None" >

                        </asp:Textbox>

    简单分析如下: 将 BorderWidth 设置为0,BorderStyle设置为None,其显示将和Label一样。Readonly设置为True,内部文字将不会被编辑。 

     下文增加一个js的控件属性修改function

    function ShowComment(selectedcontrol, control1, control2, judgePara, width1, width2, msg) {
        if (control1 != null && control2 != null) {
            if (selectedcontrol.value == judgePara) {
                control1.value = msg;
                control2.style.width = width1;
            }
            else {
                control1.value = "";
                control2.style.width = width2;
            }
        }
    }

    其调用方法

    <aspx:Textbox ID="txtCodeKubun" runat="server" ImeMode="Disabled" Width="30px" TabIndex="1"
                        onFocus="OnGreen('txtCodeKubun')"
                        onkeyup="TxtChange(this,document.getElementById('cmbCodeKubun'))"
                        onblur="TxtChangeBlur(this,document.getElementById('cmbCodeKubun'))"
                        onchange="ShowComment(this,document.getElementById('lblComment'),
                                                   document.getElementById('txtComment'),
                                                   '013','185px','400px','*Comment: how are you!')"
                        MaxLength="3" LengthAsBytes="true">
                    </aspx:Textbox>
    Love it, and you live without it
  • 相关阅读:
    如何设置body高度为浏览器高度
    h5的video下载按钮如何隐藏
    微信小程序中的子父组件传值问题
    elementUI级联选择器2(选择及回显)编辑保存
    elementUI级联选择器(选择及回显)
    vue+elementUI 表格操作行的增删改查
    单独验证非form表单中的input(限制)
    JS中去除数组中的假值(0, 空,undefined, null, false)
    vue 组件之间的传值 (父子传值、兄弟传值)
    http协议的状态码
  • 原文地址:https://www.cnblogs.com/tomclock/p/7630570.html
Copyright © 2011-2022 走看看