<%@ register src="~/uc/xwtreedropdownlist/xwtreedropdownlist.ascx" tagprefix="uc"
tagname="xwtreedropdownlist" %>
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可以,也可以回传。