问题描述
我有一个网格视图,其中在项目模板"中有四个控件,例如
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.
推荐答案
<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事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!