Can't edit dynamically created textbox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mwhalen

    Can't edit dynamically created textbox

    Hi All,

    I've dynmaically created a textbox, but I can't edit it. When I click on
    it, the cursor flashes for a second, but then goes away and I can't enter any
    text or do anything with the value in the box.

    Here's the code I've used to create the control. It's within a datagrid
    that is bound to a dataTable so the action happens in the ItemDataBound event.

    Private Sub dgItems_ItemDat aBound(ByVal sender As Object, ByVal e As
    System.Web.UI.W ebControls.Data GridItemEventAr gs) Handles dgItems.ItemDat aBound
    If e.Item.ItemType = ListItemType.It em Or e.Item.ItemType =
    ListItemType.Al ternatingItem Then
    Dim dtItems As New DataTable
    dtItems = CType(Session(" ItemsDT"), DataTable)

    'this is what I can't edit
    Dim txtQty As New TextBox
    Page.Controls.A dd(txtQty)
    e.Item.Cells(0) .Controls.Add(t xtQty)
    txtQty.ID = "txtQty" & e.Item.ItemInde x
    txtQty.EnableVi ewState = True
    txtQty.Text = dtItems.Rows(e. Item.DataSetInd ex)(0)
    txtQty.Width = WebControls.Uni t.Pixel(30)

    Dim lblDesc As New Label
    lblDesc.EnableV iewState = True
    lblDesc.Text = dtItems.Rows(e. Item.DataSetInd ex)(1)
    e.Item.Cells(1) .Controls.Add(l blDesc)

    Dim lblUnitPrice As New Label
    lblUnitPrice.En ableViewState = True
    lblUnitPrice.Te xt = dtItems.Rows(e. Item.DataSetInd ex)(2)
    e.Item.Cells(2) .Controls.Add(l blUnitPrice)

    End If
    End Sub

    Thanks.
  • mwhalen

    #2
    RE: Can't edit dynamically created textbox

    I figured out what was causing it. In the body tag of the page it had
    onblur="self.fo cus();".

    So, now I can edit the textbox, but as per my directive from above, the page
    is a popup window and needs to stay on top and that's the code that was doing
    that.

    Can anyone think of any alternative ways of making that happen?


    "mwhalen" wrote:
    [color=blue]
    > Hi All,
    >
    > I've dynmaically created a textbox, but I can't edit it. When I click on
    > it, the cursor flashes for a second, but then goes away and I can't enter any
    > text or do anything with the value in the box.
    >
    > Here's the code I've used to create the control. It's within a datagrid
    > that is bound to a dataTable so the action happens in the ItemDataBound event.
    >
    > Private Sub dgItems_ItemDat aBound(ByVal sender As Object, ByVal e As
    > System.Web.UI.W ebControls.Data GridItemEventAr gs) Handles dgItems.ItemDat aBound
    > If e.Item.ItemType = ListItemType.It em Or e.Item.ItemType =
    > ListItemType.Al ternatingItem Then
    > Dim dtItems As New DataTable
    > dtItems = CType(Session(" ItemsDT"), DataTable)
    >
    > 'this is what I can't edit
    > Dim txtQty As New TextBox
    > Page.Controls.A dd(txtQty)
    > e.Item.Cells(0) .Controls.Add(t xtQty)
    > txtQty.ID = "txtQty" & e.Item.ItemInde x
    > txtQty.EnableVi ewState = True
    > txtQty.Text = dtItems.Rows(e. Item.DataSetInd ex)(0)
    > txtQty.Width = WebControls.Uni t.Pixel(30)
    >
    > Dim lblDesc As New Label
    > lblDesc.EnableV iewState = True
    > lblDesc.Text = dtItems.Rows(e. Item.DataSetInd ex)(1)
    > e.Item.Cells(1) .Controls.Add(l blDesc)
    >
    > Dim lblUnitPrice As New Label
    > lblUnitPrice.En ableViewState = True
    > lblUnitPrice.Te xt = dtItems.Rows(e. Item.DataSetInd ex)(2)
    > e.Item.Cells(2) .Controls.Add(l blUnitPrice)
    >
    > End If
    > End Sub
    >
    > Thanks.[/color]

    Comment

    • MWells

      #3
      Re: Can't edit dynamically created textbox

      I believe there is a way in javascript to open a new window as a modal
      dialog, meaning that you can't push it behind the parent window or interact
      with the parent window until the dialog is closed.

      "mwhalen" <mwhalen@discus sions.microsoft .com> wrote in message
      news:D089A167-43C2-4767-B7FB-7DDB3B6AEE36@mi crosoft.com...[color=blue]
      > I figured out what was causing it. In the body tag of the page it had
      > onblur="self.fo cus();".
      >
      > So, now I can edit the textbox, but as per my directive from above, the[/color]
      page[color=blue]
      > is a popup window and needs to stay on top and that's the code that was[/color]
      doing[color=blue]
      > that.
      >
      > Can anyone think of any alternative ways of making that happen?
      >
      >
      > "mwhalen" wrote:
      >[color=green]
      > > Hi All,
      > >
      > > I've dynmaically created a textbox, but I can't edit it. When I click[/color][/color]
      on[color=blue][color=green]
      > > it, the cursor flashes for a second, but then goes away and I can't[/color][/color]
      enter any[color=blue][color=green]
      > > text or do anything with the value in the box.
      > >
      > > Here's the code I've used to create the control. It's within a datagrid
      > > that is bound to a dataTable so the action happens in the ItemDataBound[/color][/color]
      event.[color=blue][color=green]
      > >
      > > Private Sub dgItems_ItemDat aBound(ByVal sender As Object, ByVal e As
      > > System.Web.UI.W ebControls.Data GridItemEventAr gs) Handles[/color][/color]
      dgItems.ItemDat aBound[color=blue][color=green]
      > > If e.Item.ItemType = ListItemType.It em Or e.Item.ItemType =
      > > ListItemType.Al ternatingItem Then
      > > Dim dtItems As New DataTable
      > > dtItems = CType(Session(" ItemsDT"), DataTable)
      > >
      > > 'this is what I can't edit
      > > Dim txtQty As New TextBox
      > > Page.Controls.A dd(txtQty)
      > > e.Item.Cells(0) .Controls.Add(t xtQty)
      > > txtQty.ID = "txtQty" & e.Item.ItemInde x
      > > txtQty.EnableVi ewState = True
      > > txtQty.Text = dtItems.Rows(e. Item.DataSetInd ex)(0)
      > > txtQty.Width = WebControls.Uni t.Pixel(30)
      > >
      > > Dim lblDesc As New Label
      > > lblDesc.EnableV iewState = True
      > > lblDesc.Text = dtItems.Rows(e. Item.DataSetInd ex)(1)
      > > e.Item.Cells(1) .Controls.Add(l blDesc)
      > >
      > > Dim lblUnitPrice As New Label
      > > lblUnitPrice.En ableViewState = True
      > > lblUnitPrice.Te xt = dtItems.Rows(e. Item.DataSetInd ex)(2)
      > > e.Item.Cells(2) .Controls.Add(l blUnitPrice)
      > >
      > > End If
      > > End Sub
      > >
      > > Thanks.[/color][/color]


      Comment

      Working...