{"id":432,"date":"2010-10-01T02:27:10","date_gmt":"2010-10-01T02:27:10","guid":{"rendered":"http:\/\/enjoyasp.net\/?p=432"},"modified":"2010-10-01T02:27:10","modified_gmt":"2010-10-01T02:27:10","slug":"asp-net-textbox%e5%8f%aa%e8%af%bb%e6%97%b6%e4%b8%8d%e8%83%bd%e9%80%9a%e8%bf%87%e5%90%8e%e5%8f%b0%e8%b5%8b%e5%80%bc%e5%8f%96%e5%80%bc%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95","status":"publish","type":"post","link":"https:\/\/enjoyasp.net\/index.php\/2010\/10\/01\/asp-net-textbox%e5%8f%aa%e8%af%bb%e6%97%b6%e4%b8%8d%e8%83%bd%e9%80%9a%e8%bf%87%e5%90%8e%e5%8f%b0%e8%b5%8b%e5%80%bc%e5%8f%96%e5%80%bc%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95\/","title":{"rendered":"asp.net TextBox\u53ea\u8bfb\u65f6\u4e0d\u80fd\u901a\u8fc7\u540e\u53f0\u8d4b\u503c\u53d6\u503c\u89e3\u51b3\u529e\u6cd5"},"content":{"rendered":"<blockquote><p>?\u7ed9\u9875\u9762\u7684TextBox\u8bbe\u7f6eReadOnly=&#8221;True&#8221;\u65f6,\u5728\u540e\u53f0\u4ee3\u7801\u4e2d\u4e0d\u80fd\u8d4b\u503c\u53d6\u503c,\u4e0b\u8fb9\u51e0\u79cd\u65b9\u6cd5\u53ef\u4ee5\u907f\u514d:<\/p>\n<p>1\u3001\u4e0d\u8bbe\u7f6eReadOnly,\u8bbe\u7f6eonfocus=this.blur()<\/p>\n<div>\n<div>\n<div>C#\u4ee3\u7801 <a title=\"\u590d\u5236\u4ee3\u7801\" href=\"http:\/\/heisetoufa.javaeye.com\/blog\/462209#\"><img decoding=\"async\" src=\"http:\/\/heisetoufa.javaeye.com\/images\/icon_copy.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<\/div>\n<ol>\n<li>&lt;asp:TextBox?ID=&#8221;TextBox1&#8243;?runat=&#8221;server&#8221;?onfocus=<strong>this<\/strong>.blur()&gt;&lt;\/asp:TextBox&gt;??<\/li>\n<\/ol>\n<\/div>\n<pre>&lt;asp:TextBox ID=\"TextBox1\" runat=\"server\" onfocus=this.blur()&gt;&lt;\/asp:TextBox&gt;<\/pre>\n<p>\u6587\u672c\u6846\u4e0d\u53d8\u7070\u8272,\u4f46\u4e5f\u65e0\u6cd5\u624b\u52a8\u4fee\u6539\u5185\u5bb9,\u53ef\u4ee5\u5728\u540e\u53f0\u901a\u8fc7Text\u5c5e\u6027\u6b63\u5e38\u8d4b\u503c\u53d6\u503c<\/p>\n<p>2\u3001\u8bbe\u7f6e\u4e86ReadOnly\u5c5e\u6027\u540e\uff0c\u901a\u8fc7Request\u6765\u53d6\u503c\uff0c\u5982\u4e0b\uff1a<\/p>\n<p>\u524d\u53f0\u4ee3\u7801:<\/p>\n<div>\n<div>\n<div>C#\u4ee3\u7801 <a title=\"\u590d\u5236\u4ee3\u7801\" href=\"http:\/\/heisetoufa.javaeye.com\/blog\/462209#\"><img decoding=\"async\" src=\"http:\/\/heisetoufa.javaeye.com\/images\/icon_copy.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<\/div>\n<ol>\n<li>&lt;asp:TextBox?ID=&#8221;TextBox1&#8243;?runat=&#8221;server&#8221;?ReadOnly=&#8221;True&#8221;?&gt;&lt;\/asp:TextBox&gt;??<\/li>\n<\/ol>\n<\/div>\n<pre>&lt;asp:TextBox ID=\"TextBox1\" runat=\"server\" ReadOnly=\"True\" &gt;&lt;\/asp:TextBox&gt;<\/pre>\n<p>\u540e\u53f0\u4ee3\u7801\uff1a<\/p>\n<div>\n<div>\n<div>C#\u4ee3\u7801 <a title=\"\u590d\u5236\u4ee3\u7801\" href=\"http:\/\/heisetoufa.javaeye.com\/blog\/462209#\"><img decoding=\"async\" src=\"http:\/\/heisetoufa.javaeye.com\/images\/icon_copy.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<\/div>\n<ol>\n<li><strong>string<\/strong>?Text?=?Request.Form[&#8220;TextBox1&#8221;].Trim();??<\/li>\n<\/ol>\n<\/div>\n<pre>string Text = Request.Form[\"TextBox1\"].Trim();<\/pre>\n<p>3\u3001\u5728Page_Load()\u6b63\u8bbe\u7f6e\u6587\u672c\u6846\u7684\u53ea\u8bfb\u5c5e\u6027\uff0c\u80fd\u6b63\u5e38\u8bfb\u53d6\uff0c\u5982\u4e0b\uff1a<\/p>\n<div>\n<div>C#\u4ee3\u7801 <a title=\"\u590d\u5236\u4ee3\u7801\" href=\"http:\/\/heisetoufa.javaeye.com\/blog\/462209#\"><img decoding=\"async\" src=\"http:\/\/heisetoufa.javaeye.com\/images\/icon_copy.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<\/div>\n<div>\n<ol>\n<li><strong>protected<\/strong>?<strong>void<\/strong>?Page_Load(<strong>object<\/strong>?sender,?EventArgs?e) ??<\/li>\n<li>{ ??<\/li>\n<li>????<strong>if<\/strong>?(!Page.IsPostBack) ??<\/li>\n<li>????{ ??<\/li>\n<li>????????TextBox1.Attributes.Add(&#8220;readonly&#8221;,&#8221;true&#8221;); ??<\/li>\n<li>????} ??<\/li>\n<li>}?<\/li>\n<\/ol>\n<\/div>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>?\u7ed9\u9875\u9762\u7684TextBox\u8bbe\u7f6eReadOnly=&#8221;True&#8221;\u65f6,\u5728\u540e\u53f0\u4ee3\u7801\u4e2d\u4e0d\u80fd\u8d4b\u503c\u53d6\u503c [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[],"class_list":["post-432","post","type-post","status-publish","format-standard","hentry","category-aspdotnet"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/432","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/comments?post=432"}],"version-history":[{"count":0,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/432\/revisions"}],"wp:attachment":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/media?parent=432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/categories?post=432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/tags?post=432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}