当我使用CSS时,不会触发Textbox TextChanged事件 [英] Textbox TextChanged Event not Fires when i use CSS

查看:85
本文介绍了当我使用CSS时,不会触发Textbox TextChanged事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个网格视图,其中在项目模板"中有四个控件,例如

Textbox1,它是使用"Handler.ashx"和"JQuery"的自动完成类型. //产品名称
带有列表项的下拉列表//产品类型(仅3种类型)
Textbox2,//页数
文字框3. //份数

当用户在该Textbox1中输入文本时,它将检索数据库值以填充自动完成"文本.

实际上,我使用CSS类将用户选择的值分配给Textbox.我的问题现在是更改textbox1的值, textChanged事件未触发.

请帮帮我..


我的文本框在下面...



I have an gridview with four controls inside "item template" like

Textbox1, Which was an Autocomplete Type using "Handler.ashx" and "JQuery". //Product name
Dropdownlist, with listitems //Product type(only 3 types)
Textbox2, //Number of Pages
Textbox3. //Number of copies

When user enter text inside that Textbox1, it will retrieve database values to fill the Autocomplete text.

Actually i use an CSS class to assign the User selected values to the Textbox.My Problem is now changing the value of the textbox1, textChanged event not fired.

Please help me out..


My textbox is below...

<asp:TextBox ID="txt_prodname" runat="server" CssClass="autocompleteTXT"

                     onblur="ValidatePname(this);" Width = "100px" AutoPostBack="True" ontextchanged="txt_prodname_TextChanged"></asp:TextBox>





protected void txt_prodname_TextChanged(object sender, EventArgs e)
   {
       GridViewRow grdRow = ((System.Web.UI.WebControls.TextBox)sender).Parent.Parent as GridViewRow;
       TextBox txtprodname = (TextBox)(Grid_billing.Rows[grdRow.RowIndex].Cells[1].FindControl("txt_prodname"));
       DropDownList txttype = (DropDownList)(Grid_billing.Rows[grdRow.RowIndex].Cells[2].FindControl("ddl_Prodtype"));
       TextBox txtpages = (TextBox)(Grid_billing.Rows[grdRow.RowIndex].Cells[3].FindControl("txt_pages"));
       TextBox txtcopies = (TextBox)(Grid_billing.Rows[grdRow.RowIndex].Cells[3].FindControl("txt_Copies"));
       TextBox txtFCamt = (TextBox)(Grid_billing.Rows[grdRow.RowIndex].FindControl("txt_FCamt"));
       TextBox txtACamt = (TextBox)(Grid_billing.Rows[grdRow.RowIndex].FindControl("txt_ACamt"));
       TextBox txtExtra = (TextBox)(Grid_billing.Rows[grdRow.RowIndex].FindControl("txt_extra"));
       TextBox txtTotal = (TextBox)(Grid_billing.Rows[grdRow.RowIndex].FindControl("txt_total"));
       txttype.SelectedIndex = 0;txtpages.Text = "";
       txtcopies.Text = ""; txtACamt.Text = ""; txtFCamt.Text = "";
       txtExtra.Text = ""; txtTotal.Text = "";
       txt_assess_value.Text = ""; txt_netamt.Text = "";
   }





实际上,我知道在回发"之后,只会将选定的值分配给文本框.但是,即使我将"AUTOPOSTBACK"设置为TRUE.它不回发.

还有什么其他方法可以回传我的页面,而我的文本框不会模糊吗?
因为用户可以更改textbox2,所以先更改textbox3,然后再更改textbox1.我在textbox2和textbox3上的回发仅能正常工作.因此,我需要将textbox1发回以进行textchanged事件.

即使我没有在这里使用UPDATE PANEL ,请帮帮我.





Actually i know after Postback only the selected value will assign to the textbox. But even i gave "AUTOPOSTBACK" as TRUE. Its not postback.

Is there any other way to postback my page, while onblur of my textbox???
Because user may change textbox2, textbox3 and then textbox1. I have postback on textbox2 and textbox3 only working properly. So i need textbox1 postback to made textchanged event.

Even i didn''t use UPDATE PANEL here Please help me out.

推荐答案

您的代码看起来几乎可以.无论如何,我在网络上找到了该知识库,请尝试&让我知道.顺便说一句,您正在使用IE吗?

如果在Internet Explorer中启用了自动完成功能,则可能不会触发TextBox控件的TextChanged事件 [
You code looks like almost ok. Anyway I found this KB in web, try that & let me know. BTW are you using IE?

The TextChanged event of a TextBox control may not fire if the AutoComplete feature is enabled in Internet Explorer[^]


Atlast找到了我的解决方案,

这篇文章可能对将来的开发人员有用.....

正如我在上面的问题中提到的那样,我的页面不是回发以将文本值分配给服务器的.

让我再次清理自己,

仅使回发使控件保持其价值"

因此,我通过JAVASCRIPT的ONBLUR事件动态地回发了我的页面

喜欢

Atlast found my solution,

This post may useful for future Developers,....

As i mentioned above in my Question, my page is not postback to assign the text values to the sever.

Let me clear myself once again,

"CAUSING POSTBACK ONLY MAKES THE CONTROLS TO RETAIN THEIR VALUES"

Hence, i postback my page DYNAMICALLY through ONBLUR event of JAVASCRIPT

like

<asp:TextBox ID="txt_prodname" runat="server" Width="110px" onblur="dopost();"

                        CssClass="autocompleteTXT" AutoPostBack="True"

                        ontextchanged="txt_prodname_TextChanged"></asp:TextBox>



在我的dopost()中,我添加了如下脚本



In my dopost(), i have added my script as below

<script type="JAVASCRIPT">
function dopost()
{
__doPostBack('__Page', 'MyCustomArgument');
}
</script>




__doPostBack是ASPX页面的内置功能.有关更多信息,请参见

http://www.dotnetspider.com/resources/1521-How-call- Postback-from-Javascript.aspx [ ^ ]




__doPostBack was an inbuilt function of ASPX page. For more info, refer

http://www.dotnetspider.com/resources/1521-How-call-Postback-from-Javascript.aspx[^]


这篇关于当我使用CSS时,不会触发Textbox TextChanged事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆