Hey ...I have a textbox (txtBlockName).It is in a repeater control (So txtBlockName is repeating) .(inside a ajax accorden contro).And also I have a validation in textbox (txtBlockName) on its textChanged..(So I give its autopostback=true).My problem is when I first enter then press Tab ,then it will go to next txtBlockName and suddenly the focus is disappear..
Is this due to autopostback ...If yes ,then how will I overcome this situation...
My soucecode and code is given below
<asp:TextBox ID="txtBlockName" MaxLength="15" runat="server" Text='<%#Eval("BlockName") %>'
protected void txtBlockName_TextChanged(object sender, EventArgs e)
TextBox txtBlockName = sender as TextBox;
RepeaterItem RepDropDownRow = ((RepeaterItem)txtBlockName.Parent);
if (objBlockBusinessRule.GetBlockNameValidate(txtBlockName.Text, objBlockLibrary.BlockId))
RepBlockEntry.Visible = true;
txtBlockName.Enabled = true;
spError1.Visible = true;
lblError1.ForeColor = System.Drawing.Color.White;
lblError1.Text = "Block Name Already Exists";
catch (Exception ex)
objCommon.WriteStatus(ex.Source, "Error", ex.InnerException + "\r\n" + ex.StackTrace);
11 Jan '13 - 20:36
12 Jan '13 - 21:19
suddenly the focus is disappear..Is this due to autopostback ...If yes ,then how will I overcome this situation...
Yes. That's the reason. I see you are trying to validate the text entered on the change event. If so, I would suggest you to change the implementation to overcome it.
1. Either check the text entered on page submit via a button click. Raise alert if invalid.
2. Check the text entered using XMLHTTPRequest using client events of the textbox. Further, based on the feature you are looking for, the event should not be raised on every letter types, it should be once user typed all and leaving. So, onblur or onfocusout client side events should do.
Pick the one you like, and implement the same. Try out.
12 Jan '13 - 21:25
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)