Login  
Search All Forums
Dart Home | PowerWEB LiveControls for ASP.NET | Custom Development Reply | PowerWEB LiveControls for ASP.NET Topics | Forums   
AuthorForum: PowerWEB LiveControls for ASP.NET
Topic: Focus lost on callback when using liveplaceholder
bseibenick

From: Toledo, OH USA
Posts: 22
Member Since: 05/16/05
posted June 23, 2008 12:01 PM

I am having an issue with the tab order when I put controls inside a liveplaceholder. I have boiled it down to a simple example the shows the issue. I have a liveplaceholder in my form that has two livetextboxes in it. Each livetextbox has a textchanged event on it that just writes text to a third livetextbox, not in the liveplaceholder. When I type text in livetextbox1 and hit the tab key, the focus changes to livetextbox2, then the callback happens, the text of livetextbox3 changes and then the focus gets reset to nothing (just like when a page loads). If I hit the tab now it will put focus on livetextbox1. Unfortunately I didn't figure this out until I got done coding a page that has tons of dynamically created controls...inside a liveplaceholder.

Any help would be much appreciated. Below is the minimal code I used to reproduce the issue. I can email the file if needed. I have also upgraded to the latest file version, 1.6.1.3, and that did not fix the issue either.

Thanks,
Brian

***.aspx code***
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="focus2.aspx.vb" Inherits="Shop_focus2" %>

<%@ Register Assembly="Dart.PowerWEB.LiveControls" Namespace="Dart.PowerWEB.LiveControls"
  TagPrefix="cc1" %>

<!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>Untitled Page</title>
</head>
<body>
  <form id="form1" runat="server">
  <div>
    <cc1:LivePlaceHolder ID="ph1" runat="server">
      <cc1:LiveTextBox ID="LT1" runat="server"></cc1:LiveTextBox>
      <cc1:LiveTextBox ID="LT2" runat="server"></cc1:LiveTextBox>      
    </cc1:LivePlaceHolder>
    <cc1:LiveTextBox ID="LT5" runat="server"></cc1:LiveTextBox>
  </div>
  </form>
</body>
</html>

***.vb codebehind***
Partial Class Shop_focus2
  Inherits System.Web.UI.Page

  Protected Sub LT1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LT1.TextChanged
    LT5.Text = "LT1"
  End Sub
  Protected Sub LT2_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LT2.TextChanged
    LT5.Text = "LT2"
  End Sub
End Class

K M Drake



From: Utica, NY USA
Posts: 3406
Member Since: 07/14/00
posted June 23, 2008 4:02 PM

Hi Brian,
You may be able to replace the LivePlaceHolder with a regular PlaceHolder.

Does that work ok for you?
Thanks,
-ken
bseibenick

From: Toledo, OH USA
Posts: 22
Member Since: 05/16/05
posted June 23, 2008 4:05 PM

Replacing the LivePlaceHolder with a regular PlaceHolder "fixes" the issue in the sample, but in my actual code page I need the LivePlaceHolder since some of my callbacks can create/modify controls inside the PlaceHolder and without the LivePlaceHolder I cannot get my controls to create or update without a complete postback.

Any other ideas?
Thanks,
Brian
K M Drake



From: Utica, NY USA
Posts: 3406
Member Since: 07/14/00
posted June 24, 2008 9:05 AM

Hi Brian,
I have reported the problem as issue #4767.
Please contact Jamie Powell (support@dart.com) for updates on the status of the issue.

Does adding the LiveControlUpdate attribute to these controls work?
(Instead of using a LivePlaceHolder).
Also, you might be able to use the Visible property instead of creating them in the callback.

LiveControlUpdate="true"

Thanks,
-ken
bseibenick

From: Toledo, OH USA
Posts: 22
Member Since: 05/16/05
posted June 24, 2008 9:42 AM

When I try the LiveControlUpdate = "true" I get the error:
Type 'System.Web.UI.WebControls.PlaceHolder' does not have a public property named 'LiveControlUpdate'.

Any idaes on that one?

The reason I cannot use the visible property is that I don't know how many div sections are inside the placeholder. The reason I have it setup the way I do is because the user can add div's of textboxes on the fly. If I use a standard placeholder I can make the textchanged events work correctly, but I cannot add new div sections to the placeholder without doing a full postback.

Brian
K M Drake



From: Utica, NY USA
Posts: 3406
Member Since: 07/14/00
posted June 24, 2008 12:11 PM

Hi Brian,
It looks like this works ok in Firefox, but not in IE.

You could try using some javascript to select an element after-the-fact.

Client-side script:
<script>var focusId="";function pwAfterCallback(){if (focusId!="")setTimeout("document.getElementById('"+focusId+"').select()",500);focusId="";};</script>

In the TextChanged event handler:
//Set where the focus should go
LiveTextBox1.BufferedScript.WriteLine("focusId=""ltb2"";")

The problem with this is that it does not work without the setTimeout timer.
So there is a slight delay, and the element seems to get focus, lose it, and then get it back.
Also, you may have to adjust the timeout period to ensure that it works every time.


The best option might instead be to use a mix of PlaceHolders for the LiveControls and LivePlaceHolders for standard controls that need to be updated.

Hope it helps,
-ken
bseibenick

From: Toledo, OH USA
Posts: 22
Member Since: 05/16/05
posted June 24, 2008 2:43 PM

Ken, because my textboxes are dynamically created and share the same textchange event I had to modify your code. I was able to get it to work and I am posting the code below for you or anyone else who is experiencing this issue until this is fixed.

Thanks for the help,
Brian

***client side script
<script language="javascript" type="text/javascript">
var focusId="";
function pwAfterCallback()
{
if (focusId!="") 
     
  var control = document.getElementById(focusId);

  for (i = 0; i < control.form.elements.length; i++)
  {
    if (control.form.elements[i].tabIndex == control.tabIndex+1)
    {
      setTimeout("document.getElementById('" + control.form.elements[i].id + "').focus()",100)

      if (control.form.elements[i].type == "text")
      {
        setTimeout("document.getElementById('" + control.form.elements[i].id + "').select()",100);        
        break;
      }
    }
  }  
  focusId="";
};</script>

***codebehind
Protected Sub BundleTextChanged(ByVal sender As Dart.PowerWEB.LiveControls.LiveTextBox, ByVal e As System.EventArgs)
    Dim tb1 As Dart.PowerWEB.LiveControls.LiveTextBox = New Dart.PowerWEB.LiveControls.LiveTextBox
    tb1 = sender

*** processing code goes here ***

 tb1.BufferedScript.WriteLine("focusId=" & Chr(34) & tb1.ClientID & Chr(34) & ";")


End Sub
Reply | PowerWEB LiveControls for ASP.NET Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX