选项卡问题在文本框中的自动后备

选项卡问题在文本框中的自动后备

本文介绍了选项卡问题在文本框中的自动后备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿......我有一个文本框(txtBlockName)。它在转发器控件中(所以txtBlockName正在重复)。(在ajax accorden contro中)。我还在textChanged上对textbox(txtBlockName)进行了验证..(所以我给它的autopostback = true)。我的问题是当我第一次进入然后按Tab键,然后它将转到下一个txtBlockName并且突然焦点消失.. 这是由于autopostback ......如果是,那么我将如何克服这种情况...



我的源代码和代码如下:



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") %>'

                                                                    OnTextChanged="txtBlockName_TextChanged" AutoPostBack="true"></asp:TextBox>




protected void txtBlockName_TextChanged(object sender, EventArgs e)
        {
            try
            {
                TextBox txtBlockName = sender as TextBox;
                // FINDING THE PARENT CONTROL OF DROPDOWN INORDER TO BIND 
                RepeaterItem RepDropDownRow = ((RepeaterItem)txtBlockName.Parent);
                if (objBlockBusinessRule.GetBlockNameValidate(txtBlockName.Text, objBlockLibrary.BlockId))
                {
                    RepBlockEntry.Visible = true;

                    txtBlockName.Enabled = true;
                    //txtBlockName.Focus();
                   // txtBlockName.TabIndex = 1;
                    spError1.Visible = true;
                    lblError1.ForeColor = System.Drawing.Color.White;
                    spError1.Attributes.Add("class", "alertboxnotsavedForQuick");
                    lblError1.Text = "Block Name Already Exists";
                }
            }

            catch (Exception ex)
            {
                objCommon.WriteStatus(ex.Source, "Error", ex.InnerException + "\r\n" + ex.StackTrace);
            }
        }

推荐答案


这篇关于选项卡问题在文本框中的自动后备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 23:14