AJAX http://blogs.ugidotnet.org/franx_blog/category/AJAX.aspx AJAX it-IT Francesco Geri Subtext Version 2.6.0.0 UpdatePanel e focus delle Textbox http://blogs.ugidotnet.org/franx_blog/archive/2008/12/12/updatepanel-e-focus-delle-textbox.aspx <p>Inserendo una Textbox in un UpdatePanel (AJAX) può succedere (o succede sempre?) che la textbox perda il focus, o non lo possa prendere affatto.</p> <p>Un modo per ovviare alla cosa è di registrare uno script che imposti il focus con un piccolo ritardo rispetto alla load:</p> <div> <div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"> <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: rgb(96, 96, 96);"> 1:</span> <span style="color: rgb(0, 0, 255);">Dim</span> script <span style="color: rgb(0, 0, 255);">As</span> <span style="color: rgb(0, 0, 255);">String</span> = <span style="color: rgb(0, 96, 128);">"setTimeout("</span><span style="color: rgb(0, 96, 128);">"$('"</span> &amp; MyTextBox.ClientID &amp; <span style="color: rgb(0, 96, 128);">"').focus(); "</span><span style="color: rgb(0, 96, 128);">", 100);"</span></pre> <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);"> 2:</span> ScriptManager.RegisterStartupScript(updSearch, <span style="color: rgb(0, 0, 255);">GetType</span>(<span style="color: rgb(0, 0, 255);">String</span>), <span style="color: rgb(0, 96, 128);">"set_focus_script"</span>, script, <span style="color: rgb(0, 0, 255);">True</span>)</pre> </div> </div><img src="http://blogs.ugidotnet.org/franx_blog/aggbug/94918.aspx" width="1" height="1" /> Francesco Geri http://blogs.ugidotnet.org/franx_blog/archive/2008/12/12/updatepanel-e-focus-delle-textbox.aspx Fri, 12 Dec 2008 16:30:11 GMT http://blogs.ugidotnet.org/franx_blog/archive/2008/12/12/updatepanel-e-focus-delle-textbox.aspx#feedback 2 http://blogs.ugidotnet.org/franx_blog/comments/commentRss/94918.aspx