Pretty basic set-up. I’m creating a number of textboxes, all calling a function during the onchange event to update their value to the database. These boxes are dynamically created in the backend because the data changes based on specific criteria that can be changed on the page. Here’s the creation of the boxes:
Dim t as TableRow
tC = New TableCell
Dim txtBox As New TextBox
txtBox.ID = "SampleTextBox" & counter
txtBox.Text = dt.Rows(i)(11).ToString
txtBox.ClientIDMode = UI.ClientIDMode.Static
txtBox.Attributes.Add("onchange", "return UpdateLabTestValue('" & txtBox.ClientID & "');")
tC.CssClass = "padBoth"
tC.Controls.Add(txtBox)
t.Cells.Add(tC)
tblResults.Rows.Add(t)
On the HTML side of the ball:
<asp:UpdatePanel ID="uplResults" runat="server">
<ContentTemplate>
<div class="formContentLeft">
<fieldset class="collapsible" style="width: 90%;">
<legend>Results</legend>
<div class="formContentLeft">
<div class="formField">
<span class="formInline">Status: </span><span class="formInput">
<asp:DropDownList ID="dlStatus" runat="server" /></span>
</div>
</div>
<br />
<br />
<asp:Table ID="tblResults" runat="server" />
<div class="centeredButtonRow">
<asp:Button ID="btnSaveResults" runat="server" Text="Save" />
</div>
<asp:Label ID="errorMessage" runat="server" CssClass="errorMessage" />
</fieldset>
</div>
</ContentTemplate>
</asp:UpdatePanel>
When I enter a number into the Textbox, the event fires as expected, but it fires twice. Any thoughts?
Changed this to an “onblur” and it works. There must be something else causing the fire for the change, although the same textbox is firing it off twice. In any case, I resolved this by switching to onblur.