Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
hi,
 
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 = "";
    }
 

 
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.
Posted 7-Aug-11 22:28pm
Edited 10-Aug-11 20:36pm
v6
Comments
thatraja at 8-Aug-11 3:33am
   
Show the code for txt_prodname_TextChanged
jkarthick1989 at 8-Aug-11 3:45am
   
Please check my code above....
jkarthick1989 at 8-Aug-11 3:52am
   
Hope you dont need any Explanation. When user change the value of "txtprodname" i need to refresh the entire Row. Thats wat i need this Event.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  
Comments
jkarthick1989 at 9-Aug-11 8:53am
   
yaa...I'm using IE8.
I refered your link already...before i made this post
 
Anyways thanks for your reply. But still i cant find solution :(
Now i just change this event code to the nearby Dropdownlist. Please Post me if you find any Solution
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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>
 
In my dopost(), i have added my script as below
 
<script type="JAVASCRIPT">
function dopost()
{
__doPostBack('__Page', 'MyCustomArgument');
}
</script>
 

__doPostBack was an inbuilt function of ASPX page. For more info, refer
 
http://www.dotnetspider.com/resources/1521-How-call-Postback-from-Javascript.aspx[^]
  Permalink  
Comments
vipinvasu at 1-Aug-12 4:13am
   
Hi,
Thank u so much..Your code works good..
jkarthick1989 at 2-Aug-12 1:07am
   
Welcome vipinvasu !!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 565
1 Maciej Los 319
2 Richard MacCutchan 220
3 BillWoodruff 164
4 Mathew Soji 160
0 OriginalGriff 8,654
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,229
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 11 Aug 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100