关于Web文本框和HTML文本框区别(RandOnly、Disabled )

作者:袖梨 2022-06-25


<%@ register src="~/uc/xwtreedropdownlist/xwtreedropdownlist.ascx" tagprefix="uc"
    tagname="xwtreedropdownlist" %>


   


   


   
       
           
           
           
           
       
       
           
           
           
           
       
       
           
           
           
           
       
   

                 
           

                newreadonly
           

                readonly
           

                disabled
           

                asp教程:textbox
           

                                    oncut="return false" text="txtnewreadonly1">
           

               
           

               
           

                input:text
           

                                    oncut="return false" value="txtnewreadonly2" />
           

               
           

               
           

   
   
   

        protected void button1_click( object sender, eventargs e )
        {
            response.write( "asp:textbox
" );
            response.write( string.format( "txtnewreadonly1: {0}
", request.form[ "txtnewreadonly1" ] ) );
            response.write( string.format( "txtreadonly1: {0}
", request.form[ "txtreadonly1" ] ) );
            response.write( string.format( "txtdisabled1: {0}
", request.form[ "txtdisabled1" ] ) );

            response.write( "
" );

            response.write( "input:text
" );
            response.write( string.format( "txtnewreadonly2: {0}
", request.form[ "txtnewreadonly2" ] ) );
            response.write( string.format( "txtreadonly2: {0}
", request.form[ "txtreadonly2" ] ) );
            response.write( string.format( "txtdisabled2: {0}
", request.form[ "txtdisabled2" ] ) );
        }


1、readonly只针对input(text/password)和textarea有效,而disabled对于所有的表单元素有效,包括select,radio,checkbox,button等。

    2、在表单元素使用了disabled后,我们将表单以post或者get的方式提交的话,这个元素的值不会被传递出去,而readonly会将该值传递出去。    

    需要一个这样的文本框,不能手工更改内容,但js可以,也可以回传。

 

相关文章

精彩推荐