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
  • 相关阅读:
    [转载]项目风险管理七种武器之引言
    [转载]基于TFS实践敏捷-Scrum模式运用
    [转载]基于TFS实践敏捷-工作项跟踪
    [转载]TFS入门指南
    SVN — subclipse操作指引
    Java 中 方法名或类名 变更 同时 更新 所有引用的 类名或方法名 的解决方案
    Java import javax.servlet 出错
    java 中 SVN 设置所有文件及子目录 needs-lock, svn 提交时自动设置 needs-lock, 及版本不一致问题
    vmware 传输(vmdb)错误-32:pipe:read failed 解决方法
    Web.xml配置详解
  • 原文地址:https://www.cnblogs.com/tomclock/p/7630570.html
Copyright © 2011-2022 走看看