Reputation: 2305
I have a repeater that places 600+ textboxes filled with data on my page. A typical user will edit several of these.
I would like the OnTextChanged event to run when I hit a save button, but it's not working.
All of my textboxes have the property OnTextChanged="TextBoxChanged"
When my user selects the save button
<asp:Button ID="SaveChangesBtn" CssClass="SaveAndNextBtn" runat="server"
Text="Save Changes" onclick="SaveChangesBtnClick" />
I would like the TextBoxChanged event to run for each textbox that has been changed. How can I implement this?
Upvotes: 1
Views: 1658
Reputation: 460048
Do you rebind the repeater on every postback or have you wrapped the databinding stuff (as you should) in a !IsPostback-check?
if(!IsPostBack)
DataBindRepeater();
If you databind web-databound controls on postbacks, all changes are lost and events won't be triggered.
Upvotes: 4
Reputation: 2514
I'm afraid OnTextChanged isn't quite what you are looking for then. OnTextChanged fires after a control has been entered, changed and then left (lost focus), so it fires when you select the next object.
you could use the OnTextChanged to accumulate a list of the IDs of the textboxes with changed contents, and then when you save, just loop over all the changed boxes to perform whatever task you like.
Upvotes: 0