Hi Madison,
I have made a test application based on your description. After testing it,
I found that if we type some value into the first TextBox and then click
the second one, the cursor would disappear and we cannot type value into
the second one. Please tell me whether this behavior is the same to what
your mentioned.
If so, let me explain the cause of the behavior first.
We type some values into the first TextBox and then click the other place
of the window, the page would be refreshed because we set the AutoPostBack
property of the TextBox with true. Although we click the second TextBox,
the application would run the server side post back firstly whether these
controls are inside the UpdatePanel or not. The cursor which is inside the
second TextBox would disappear because the page's post back. This is the
default setting by the ASP.NET Life-cycle.
If these TextBoxes are placed into an UpdatePanel, we cannot see the
refresh of the page, so, the cursor's disappearance would be weird.
To make a workaround, we can set the AutoPostBack property with false. In
the second TextBox's client side click event, doPostBack and store the
current TextBox into a HiddenField. In the end, set the focus() function
after the asynchronous request is ended.
Refer to this sample:
<%@ Page Language="vb" AutoEventWireup="false"
CodeBehind="TestUpdatePanel.aspx.vb"
Inherits="_44456996.TestUpdatePanel" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:HiddenField ID="HF1" runat="server" />
<div style="border-style: solid; border-width: thin">
TextBoxes outside the UpdatePanel<br />
Type into first TextBox and then click the second one,<br />
the page would be refreshed.<br />
<asp:TextBox ID="TextBox1" runat="server"
onclick="TextBoxOnClick(this)" AutoPostBack="false"></asp:TextBox><br />
<asp:TextBox ID="TextBox2" runat="server"
onclick="TextBoxOnClick(this)" AutoPostBack="false"></asp:TextBox><br />
<asp:TextBox ID="TextBox3" runat="server"
onclick="TextBoxOnClick(this)" AutoPostBack="false"></asp:TextBox><br />
</div>
<hr />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div style="border-style: solid; border-width: thin">
TextBoxes inside the UpdatePanel<br />
Type into first TextBox and then click the second
one,<br />
the page would NOT be refreshed.<br />
That's what your mentioned.<br />
<asp:TextBox ID="TextBox4" runat="server"
onclick="TextBoxOnClick(this)" AutoPostBack="false"></asp:TextBox><br />
<asp:TextBox ID="TextBox5" runat="server"
onclick="TextBoxOnClick(this)" AutoPostBack="false"></asp:TextBox><br />
<asp:TextBox ID="TextBox6" runat="server"
onclick="TextBoxOnClick(this)" AutoPostBack="false"></asp:TextBox><br />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(
function(sender, e) {
if ($get("HF1").value) {
var textbox = $get($get("HF1").value);
textbox.select();
textbox.focus();
}
});
function TextBoxOnClick(tb) {
if ($get("HF1").value != tb.id) {
$get("HF1").value = tb.id;
__doPostBack(tb.id, "");
}
}
</script>
</form>
</body>
</html>
Note that, to make these script run correctly, please place the script tag
under the ScriptManager control.
Another choice is set the AutoPostBack property with false and use a Button
to make a post back.
Meanwhile, I think these tutorials of the UpdatePanel can help you use it
and understand the AJAX function more clearly:
http://www.asp.net/AJAX/Documentation/Live/overview/UpdatePanelOverview.aspx
http://www.asp.net/AJAX/Documentation/Live/tutorials/UsingUpdatePanelControl
s.aspx
Understanding Partial Page Updates with ASP.NET AJAX
http://www.asp.net/learn/ajax/tutorial-01-cs.aspx
How Do I:Implement Dynamic Partial-Page Updates with ASP.NET AJAX?
http://www.asp.net/learn/ajax-videos/video-78.aspx
How Do I:Use JavaScript to Refresh an ASP.NET AJAX UpdatePanel?
http://www.asp.net/learn/ajax-videos/video-172.aspx
How Do I:Use the Conditional UpdateMode of the UpdatePanel?
http://www.asp.net/learn/ajax-videos/video-177.aspx
How Do I:Trigger an UpdatePanel Refresh from a DropDownList Control?
http://www.asp.net/learn/ajax-videos/video-183.aspx
How To Dynamically Change CSS Using the ASP.NET AJAX UpdatePanel
http://www.asp.net/learn/ajax-videos/video-285.aspx
--
Sincerely,
Zhi-Qiang Ni
Microsoft Online Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
MSDN Managed Newsgroup support offering is for non-urgent issues where an
initial response from the community or a Microsoft Support Engineer within
2 business day is acceptable. Please note that each follow up response may
take approximately 2 business days as the support professional working with
you may need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations that require urgent,
real-time or phone-based interactions. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
--------------------
| Thread-Topic: AJAX UpdatePanel lost focus
| thread-index: AcqTs/64Rn3xAuuZRU6L+HzRGFvxbg==
| X-WBNR-Posting-Host: 165.189.6.46
| From: Madison <
[email protected]>
| Subject: AJAX UpdatePanel lost focus
| Date: Tue, 12 Jan 2010 10:21:01 -0800
| Lines: 6
| Message-ID: <
[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4325
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Path: TK2MSFTNGHUB02.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet:95729
| NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi There,
| I'm writing web application VB VS2008 with ajax. My page has user
control
| and textboxes. I group the textbox together and have 3 <asp:updatePanel
...
| updatemode="Conditional"> each group has about 6 textboxes each textboxes
| has AutoPostBack=true when I go to the third textbox with focus on, I
cannot
| type any characters to the box. Please helps. Thanks.
|