Dynamic webpage OnClick not firing after OnChange

54530 pts.
dynamic controls
I'm still new to the .NET world so forgive me if this is trivial. I have a simple dynamic web page. If the user changes the text in the textbox and clicks the k or l button before tabbing out of text box, the onchange is the only event that fires. Each function works fine independently. Click a button and change the label to show what was clicked. I cannot figure how to get both to fire if they change text and click the button before tabbing out. I've looked into things like onblur, delays, onfocus.. but could not get anything to work. Making my head spin. Is this headache because the page is built dynamically ?? Any help would be great. If it's impossible to be done this way I'm going after the person who said "Give it a try and let me know what you find out". It's been 2 days of research. Here's the ASPX code.

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebApplication5.Default2" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!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">
<script type="text/javascript">

function ButtonClick(e) {
    var lbl3text = document.getElementById('Label3');
    lbl3text.innerText = (e.value + " clicked");

function tbchanged(e) {
    var oldtbxtext = document.getElementById('OldBox1');
    oldtbxtext.innerText = (e.defaultValue);

    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <asp:Panel ID="Panel1" runat="server" BorderStyle="Groove" Height="400px"
                style="margin-right: 21px" Width="1100px" BorderWidth="5px">

and here's the VB code

Imports System.Web.UI.Page Imports System.Web.UI.WebControls Partial Public Class Default2 Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If IsPostBack Then Else End If CreateControls() End Sub Protected Sub CreateControls() Dim lbl3 As New Label lbl3.ID = "Label3" lbl3.Text = "MyLabel" lbl3.Style("Top") = 200.ToString & "px" lbl3.Style("Left") = 25.ToString & "px" lbl3.Style("Position") = "absolute" lbl3.Width = 175 lbl3.EnableViewState = True Panel1.Controls.Add(lbl3) Dim tblbl As New Label tblbl.ID = "TBLabel" tblbl.Text = "Textbox:" tblbl.Style("Top") = 100.ToString & "px" tblbl.Style("Left") = 430.ToString & "px" tblbl.Style("Position") = "absolute" tblbl.Width = 45 tblbl.EnableViewState = True Panel1.Controls.Add(tblbl) Dim tBox As New TextBox tBox.ID = "TextBox1" tBox.Text = "TxtBox Value" tBox.Style("Top") = 100.ToString & "px" tBox.Style("Left") = 500.ToString & "px" tBox.Width = 200 tBox.Height = 50 tBox.TextMode = TextBoxMode.MultiLine tBox.Style("Position") = "absolute" tBox.EnableViewState = True tBox.AutoPostBack = True Panel1.Controls.Add(tBox) tBox.Attributes.Add("onblur", "javascript:tbchanged(this); ") Dim oldtblbl As New Label oldtblbl.ID = "OldTBLabel" oldtblbl.Text = "Old Textbox:" oldtblbl.Style("Top") = 100.ToString & "px" oldtblbl.Style("Left") = 725.ToString & "px" oldtblbl.Style("Position") = "absolute" oldtblbl.Width = 150 oldtblbl.EnableViewState = True Panel1.Controls.Add(oldtblbl) Dim oldtbx As New TextBox oldtbx.ID = "OldBox1" oldtbx.Style("Top") = 100.ToString & "px" oldtbx.Style("Left") = 825.ToString & "px" oldtbx.Width = 200 oldtbx.Height = 50 oldtbx.TextMode = TextBoxMode.MultiLine oldtbx.Style("Position") = "absolute" oldtbx.EnableViewState = True oldtbx.Text = " " Panel1.Controls.Add(oldtbx) Dim kButton As New Button kButton.ID = "Buttonk" kButton.Text = "Button K" kButton.Style("Top") = 200.ToString & "px" kButton.Style("Left") = 450.ToString & "px" kButton.Style("Position") = "absolute" kButton.Width = 200 kButton.EnableViewState = True Panel1.Controls.Add(kButton) kButton.Attributes.Add("onclick", "javascript:ButtonClick(this); return false;") Dim lButton As New Button lButton.ID = "Buttonl" lButton.Text = "Button L" lButton.Style("Top") = 200.ToString & "px" lButton.Style("Left") = 450.ToString & "px" lButton.Style("Position") = "absolute" lButton.Width = 200 lButton.EnableViewState = True Panel1.Controls.Add(lButton) kButton.Attributes.Add("onclick", "javascript:ButtonClick(this); return false;") End Sub End Class

Thanks in advance for any help !!

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question:  

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: