Valhalla Legends Forums Archive | .NET Platform | Textbox Events [asp.net]

AuthorMessageTime
Imperceptus
I have a grid view that I am casting data out of into a textbox.
[code]
  Protected Sub gvSpread_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvSpread.RowDataBound

       Select Case e.Row.RowType
           Case DataControlRowType.DataRow

               Dim txtTicker As TextBox = _
                   TryCast(e.Row.Cells(0).FindControl("TextBox1"), TextBox)

               txtTicker.Attributes.Add("onblur", "validate();")
               txtTicker.Attributes.Add("autocomplete", "off")
               txtTickers.Add(txtTicker.UniqueID)

               AddHandler txtTicker.TextChanged, AddressOf txtTicker_Changed

               Dim txtValue As TextBox = TryCast(e.Row.Cells(1).FindControl("TextBox2"), TextBox)
               txtValue.Text = FormatCurrency(txtValue.Text, 2)
               txtValue.Attributes.Add("onKeyUp", "totalfields();")

               AddHandler txtValue.TextChanged, AddressOf txtTicker_Changed
               ValueTotal += Val(txtValue.Text)
[/code]

Is expecting the AddHandler statements to actually work a fantasy?  
October 6, 2009, 6:42 PM
Myndfyr
[quote author=Imperceptus link=topic=18083.msg183480#msg183480 date=1254854577]
Is expecting the AddHandler statements to actually work a fantasy?  
[/quote]

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.autopostback.aspx

And actually, yes.  Web forms controls don't really maintain state like you're trying for (you'd have to rebind the event every time the page was posted-back).
October 6, 2009, 8:42 PM
Imperceptus
Alrighty, thanks. 

that sucks.

October 6, 2009, 9:19 PM

Search