From: Madison on
Hi Zhi-Qiang Ni,

Thank you for your sample codes. I created new page and pasted your sample
and run. It did not work for me. I still have the same problem when I try to
enter the values into the textbox.



"Zhi-Qiang Ni[MSFT]" wrote:

> Hi Madison,
>
> I have modified some of my code, maybe this behavior can be more smoother.
> I use a HiddenField to store the clicked TextBox's ID and then setfocus
> back in the Timer's tick event.
>
> Here is the code:
> <%@ 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" />
> <asp:UpdatePanel ID="UpdatePanel1" runat="server">
> <ContentTemplate>
> <div style="border-style: solid; border-width: thin">
> Value1:<asp:TextBox ID="TextBox1" runat="server"
> onclick="TextBoxOnClick(this)" onblur="TextBoxOnBlur(this)"
> AutoPostBack="false"></asp:TextBox>
> <asp:Label ID="Label1" runat="server"
> Text="Label"></asp:Label><br />
> Value2:<asp:TextBox ID="TextBox2" runat="server"
> onclick="TextBoxOnClick(this)" onblur="TextBoxOnBlur(this)"
> AutoPostBack="false"></asp:TextBox>
> <asp:Label ID="Label2" runat="server"
> Text="Label"></asp:Label><br />
> Value3:<asp:TextBox ID="TextBox3" runat="server"
> onclick="TextBoxOnClick(this)" onblur="TextBoxOnBlur(this)"
> AutoPostBack="false"></asp:TextBox>
> <asp:Label ID="Label3" runat="server"
> Text="Label"></asp:Label><br />
> Value4:<asp:TextBox ID="TextBox4" runat="server"
> onclick="TextBoxOnClick(this)" onblur="TextBoxOnBlur(this)"
> AutoPostBack="false"></asp:TextBox>
> <asp:Label ID="Label4" runat="server"
> Text="Label"></asp:Label><br />
> Value5:<asp:TextBox ID="TextBox5" runat="server"
> onclick="TextBoxOnClick(this)" onblur="TextBoxOnBlur(this)"
> AutoPostBack="false"></asp:TextBox>
> <asp:Label ID="Label5" runat="server"
> Text="Label"></asp:Label><br />
> SUM:<asp:TextBox ID="TextBox6" runat="server"
> AutoPostBack="false" ReadOnly="true"></asp:TextBox><br />
> <asp:Timer ID="Timer1" runat="server" Interval="2000">
> </asp:Timer>
> </div>
> <asp:TextBox ID="TextBox7" runat="server"></asp:TextBox>
> </ContentTemplate>
> </asp:UpdatePanel>
> </div>
>
> <script type="text/javascript">
> function TextBoxOnClick(tb) {
> $get("HF1").value = tb.id;
> }
>
> function TextBoxOnBlur(tb) {
> $get("HF1").value = "";
> }
> </script>
>
> <script runat="server">
> Private Sub Sum()
>
> If String.IsNullOrEmpty(TextBox1.Text) Then
> Label1.Text = 0
> Else
> Label1.Text = TextBox1.Text
> End If
> If String.IsNullOrEmpty(TextBox2.Text) Then
> Label2.Text = 0
> Else
> Label2.Text = TextBox2.Text
> End If
> If String.IsNullOrEmpty(TextBox3.Text) Then
> Label3.Text = 0
> Else
> Label3.Text = TextBox3.Text
> End If
> If String.IsNullOrEmpty(TextBox4.Text) Then
> Label4.Text = 0
> Else
> Label4.Text = TextBox4.Text
> End If
> If String.IsNullOrEmpty(TextBox5.Text) Then
> Label5.Text = 0
> Else
> Label5.Text = TextBox5.Text
> End If
>
> TextBox6.Text = (CInt(Label1.Text) + CInt(Label2.Text) +
> CInt(Label3.Text) + CInt(Label4.Text) + CInt(Label5.Text)).ToString
>
> End Sub
>
> Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Timer1.Tick
> Sum()
> If Not String.IsNullOrEmpty(HF1.Value) Then
> ScriptManager1.SetFocus(HF1.Value)
> 'ScriptManager.RegisterClientScriptBlock(Me.Page,
> GetType(Page), "select", "$get('" + HF1.Value + "').select();", True)
> End If
> End Sub
>
> </script>
>
> </form>
> </body>
> </html>
>
> --
> 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
> ==================================================
>
>
> .
>
From: Zhi-Qiang Ni[MSFT] on
Hi Madison,

I try to achieve your goal by using the client side function. Refer to this
code:

<%@ Page Language="vb" AutoEventWireup="false"
CodeBehind="TestClientFunction.aspx.vb"
Inherits="_44456996.TestClientFunction" %>

<!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" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div style="border-style: solid; border-width: thin">
Value1:<asp:TextBox ID="TextBox1" runat="server"
onblur="TextBoxOnBlur()" onkeypress="TextBoxOnKeyPress()"
AutoPostBack="false"></asp:TextBox>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator1" runat="server" ErrorMessage="Please enter
a Number"
ControlToValidate="TextBox1"
ValidationExpression="\d+"></asp:RegularExpressionValidator>
<asp:Label ID="Label1" runat="server" ></asp:Label><br
/>
Value2:<asp:TextBox ID="TextBox2" runat="server"
onblur="TextBoxOnBlur()" onkeypress="TextBoxOnKeyPress()"
AutoPostBack="false"></asp:TextBox>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator2" runat="server" ErrorMessage="Please enter
a Number"
ControlToValidate="TextBox2"
ValidationExpression="\d+"></asp:RegularExpressionValidator>
<asp:Label ID="Label2" runat="server" ></asp:Label><br
/>
Value3:<asp:TextBox ID="TextBox3" runat="server"
onblur="TextBoxOnBlur()" onkeypress="TextBoxOnKeyPress()"
AutoPostBack="false"></asp:TextBox>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator3" runat="server" ErrorMessage="Please enter
a Number"
ControlToValidate="TextBox3"
ValidationExpression="\d+"></asp:RegularExpressionValidator>
<asp:Label ID="Label3" runat="server" ></asp:Label><br
/>
Value4:<asp:TextBox ID="TextBox4" runat="server"
onblur="TextBoxOnBlur()" onkeypress="TextBoxOnKeyPress()"
AutoPostBack="false"></asp:TextBox>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator4" runat="server" ErrorMessage="Please enter
a Number"
ControlToValidate="TextBox4"
ValidationExpression="\d+"></asp:RegularExpressionValidator>
<asp:Label ID="Label4" runat="server" ></asp:Label><br
/>
Value5:<asp:TextBox ID="TextBox5" runat="server"
onblur="TextBoxOnBlur()" onkeypress="TextBoxOnKeyPress()"
AutoPostBack="false"></asp:TextBox>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator5" runat="server" ErrorMessage="Please enter
a Number"
ControlToValidate="TextBox5"
ValidationExpression="\d+"></asp:RegularExpressionValidator>
<asp:Label ID="Label5" runat="server" ></asp:Label><br
/>
SUM:<asp:TextBox ID="TextBox6" runat="server"
AutoPostBack="true" ReadOnly="true"></asp:TextBox><br />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>

<script type="text/javascript">

function TextBoxOnBlur(tb) {
Sum();
}

function TextBoxOnKeyPress() {
if (event.keyCode == 13) {
Sum();
}
}

function Sum() {

if (!Page_IsValid) { return; }

var value = new Array(5);
var SumValue = 0;

for (i = 1; i < 6; i++) {
if ($get("TextBox" + i).value == "") {
value[i] = 0;
} else {
value[i] = parseInt($get("TextBox" + i).value);
}

$get("Label" + i).innerHTML = value[i];
SumValue = SumValue + value[i];
}

$get("TextBox6").value = SumValue.toString();
}

</script>

</form>
</body>
</html>

--
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: AcqVLFe77QoByPq0RQOM9yTz7MzwkA==
| X-WBNR-Posting-Host: 165.189.6.46
| From: Madison <Madison(a)discussions.microsoft.com>
| References: <338C3C58-3CC7-48A4-8633-5755964ADCEB(a)microsoft.com>
<4Q4hnYDlKHA.2492(a)TK2MSFTNGHUB02.phx.gbl>
<45FC085E-BAEA-4344-9576-F28A45F462A7(a)microsoft.com>
<o2xwB9PlKHA.3976(a)TK2MSFTNGHUB02.phx.gbl>
| Subject: RE: AJAX UpdatePanel lost focus
| Date: Thu, 14 Jan 2010 07:15:01 -0800
| Lines: 157
| Message-ID: <D514D9E3-BA53-4E90-86DB-11FD0BFE277A(a)microsoft.com>
| 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:95775
| NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi Zhi-Qiang Ni,
|
| Thank you for your sample codes. I created new page and pasted your
sample
| and run. It did not work for me. I still have the same problem when I try
to
| enter the values into the textbox.
|
|

From: Madison on
Hi Zhi-Qiang Ni,

Thank you for your help. Your samples for using the client side give me the
idea that I will switch my coding to use javascript for display the total
check and validation. I still have the server side validation before saving
to database. I thought that AJAX will help me with less coding but I guess
not. I hope that the new release VS2010 will make the things better. Thank
you again for your helps.


"Zhi-Qiang Ni[MSFT]" wrote:

> Hi Madison,
>
> I try to achieve your goal by using the client side function. Refer to this
> code:
>
> <%@ Page Language="vb" AutoEventWireup="false"
> CodeBehind="TestClientFunction.aspx.vb"
> Inherits="_44456996.TestClientFunction" %>
>
> <!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" />
> <asp:UpdatePanel ID="UpdatePanel1" runat="server">
> <ContentTemplate>
> <div style="border-style: solid; border-width: thin">
> Value1:<asp:TextBox ID="TextBox1" runat="server"
> onblur="TextBoxOnBlur()" onkeypress="TextBoxOnKeyPress()"
> AutoPostBack="false"></asp:TextBox>
> <asp:RegularExpressionValidator
> ID="RegularExpressionValidator1" runat="server" ErrorMessage="Please enter
> a Number"
> ControlToValidate="TextBox1"
> ValidationExpression="\d+"></asp:RegularExpressionValidator>
> <asp:Label ID="Label1" runat="server" ></asp:Label><br
> />
> Value2:<asp:TextBox ID="TextBox2" runat="server"
> onblur="TextBoxOnBlur()" onkeypress="TextBoxOnKeyPress()"
> AutoPostBack="false"></asp:TextBox>
> <asp:RegularExpressionValidator
> ID="RegularExpressionValidator2" runat="server" ErrorMessage="Please enter
> a Number"
> ControlToValidate="TextBox2"
> ValidationExpression="\d+"></asp:RegularExpressionValidator>
> <asp:Label ID="Label2" runat="server" ></asp:Label><br
> />
> Value3:<asp:TextBox ID="TextBox3" runat="server"
> onblur="TextBoxOnBlur()" onkeypress="TextBoxOnKeyPress()"
> AutoPostBack="false"></asp:TextBox>
> <asp:RegularExpressionValidator
> ID="RegularExpressionValidator3" runat="server" ErrorMessage="Please enter
> a Number"
> ControlToValidate="TextBox3"
> ValidationExpression="\d+"></asp:RegularExpressionValidator>
> <asp:Label ID="Label3" runat="server" ></asp:Label><br
> />
> Value4:<asp:TextBox ID="TextBox4" runat="server"
> onblur="TextBoxOnBlur()" onkeypress="TextBoxOnKeyPress()"
> AutoPostBack="false"></asp:TextBox>
> <asp:RegularExpressionValidator
> ID="RegularExpressionValidator4" runat="server" ErrorMessage="Please enter
> a Number"
> ControlToValidate="TextBox4"
> ValidationExpression="\d+"></asp:RegularExpressionValidator>
> <asp:Label ID="Label4" runat="server" ></asp:Label><br
> />
> Value5:<asp:TextBox ID="TextBox5" runat="server"
> onblur="TextBoxOnBlur()" onkeypress="TextBoxOnKeyPress()"
> AutoPostBack="false"></asp:TextBox>
> <asp:RegularExpressionValidator
> ID="RegularExpressionValidator5" runat="server" ErrorMessage="Please enter
> a Number"
> ControlToValidate="TextBox5"
> ValidationExpression="\d+"></asp:RegularExpressionValidator>
> <asp:Label ID="Label5" runat="server" ></asp:Label><br
> />
> SUM:<asp:TextBox ID="TextBox6" runat="server"
> AutoPostBack="true" ReadOnly="true"></asp:TextBox><br />
> </div>
> </ContentTemplate>
> </asp:UpdatePanel>
> </div>
>
> <script type="text/javascript">
>
> function TextBoxOnBlur(tb) {
> Sum();
> }
>
> function TextBoxOnKeyPress() {
> if (event.keyCode == 13) {
> Sum();
> }
> }
>
> function Sum() {
>
> if (!Page_IsValid) { return; }
>
> var value = new Array(5);
> var SumValue = 0;
>
> for (i = 1; i < 6; i++) {
> if ($get("TextBox" + i).value == "") {
> value[i] = 0;
> } else {
> value[i] = parseInt($get("TextBox" + i).value);
> }
>
> $get("Label" + i).innerHTML = value[i];
> SumValue = SumValue + value[i];
> }
>
> $get("TextBox6").value = SumValue.toString();
> }
>
> </script>
>
> </form>
> </body>
> </html>
>
> --
> 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: AcqVLFe77QoByPq0RQOM9yTz7MzwkA==
> | X-WBNR-Posting-Host: 165.189.6.46
> | From: Madison <Madison(a)discussions.microsoft.com>
> | References: <338C3C58-3CC7-48A4-8633-5755964ADCEB(a)microsoft.com>
> <4Q4hnYDlKHA.2492(a)TK2MSFTNGHUB02.phx.gbl>
> <45FC085E-BAEA-4344-9576-F28A45F462A7(a)microsoft.com>
> <o2xwB9PlKHA.3976(a)TK2MSFTNGHUB02.phx.gbl>
> | Subject: RE: AJAX UpdatePanel lost focus
> | Date: Thu, 14 Jan 2010 07:15:01 -0800
> | Lines: 157
> | Message-ID: <D514D9E3-BA53-4E90-86DB-11FD0BFE277A(a)microsoft.com>
> | 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:95775
> | NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
> |
> | Hi Zhi-Qiang Ni,
> |
> | Thank you for your sample codes. I created new page and pasted your
> sample
> | and run. It did not work for me. I still have the same problem when I try
> to
> | enter the values into the textbox.
> |
> |
>
> .
>
From: Zhi-Qiang Ni[MSFT] on
Hi Madison,

Thanks for your understanding of my supporting. The Ajax does help us
enable the asynchronous post back and partial refresh of the page with less
coding. However, the problem-we cannot stay the cursor in the client side
TextBox after a PostBack - is a default behavior whether we use the
UpdatePanel or not. I have explained the reason of it in my last reply. The
page needs to reload after the first TextBox is on blur. So, it's easy to
focus back to the first TextBox but hard to remember the client side click
of the next TextBox.

You can enjoy the other convenient and useful functions of the ASP.NET AJAX
and AjaxControlToolkit:
http://www.asp.net/ajax/
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Default.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: AcqV+WwQXiU1Nt3nSCe1ILIw4+BHNg==
| X-WBNR-Posting-Host: 165.189.6.46
| From: Madison <Madison(a)discussions.microsoft.com>
| References: <338C3C58-3CC7-48A4-8633-5755964ADCEB(a)microsoft.com>
<4Q4hnYDlKHA.2492(a)TK2MSFTNGHUB02.phx.gbl>
<45FC085E-BAEA-4344-9576-F28A45F462A7(a)microsoft.com>
<o2xwB9PlKHA.3976(a)TK2MSFTNGHUB02.phx.gbl>
<D514D9E3-BA53-4E90-86DB-11FD0BFE277A(a)microsoft.com>
<A0IWWHblKHA.5176(a)TK2MSFTNGHUB02.phx.gbl>
| Subject: RE: AJAX UpdatePanel lost focus
| Date: Fri, 15 Jan 2010 07:43:02 -0800
| Lines: 196
| Message-ID: <4BEE0E13-85AE-41AA-9265-4EC398E2B0E3(a)microsoft.com>
| 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:95795
| NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi Zhi-Qiang Ni,
|
| Thank you for your help. Your samples for using the client side give me
the
| idea that I will switch my coding to use javascript for display the total
| check and validation. I still have the server side validation before
saving
| to database. I thought that AJAX will help me with less coding but I
guess
| not. I hope that the new release VS2010 will make the things better.
Thank
| you again for your helps.
|
|