locked
how to avoid the automatic textchanged fire event which occurs unecessarily on button click event + asp.net C# RRS feed

  • Question

  • how to avoid the automatic textchanged fire event which occurs unecessarily on button click event + asp.net C#
    • Moved by Kristin Xie Thursday, January 15, 2015 1:51 AM asp.net related
    Wednesday, January 14, 2015 4:48 AM

Answers

  • Hi Bhagghu,

    For questions related to ASP.NET use the ASP.NET forum     
    You should get more, better and faster answers on the other forum.  Thanks, ahead of time.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Just Karl Monday, February 2, 2015 11:11 PM
    Thursday, January 15, 2015 1:50 AM

All replies

  • There is no built-in functionality that set this event to fire, it's always added by developer. Are you talking about that text that gets cleared whenever you click inside asp.net Textbox control?


    Fouad Roumieh

    Wednesday, January 14, 2015 6:15 AM
  • Actually ajax calender extender is calling the page load again for the particular textbox when button is clicked.how to avoid this ? i need the calender extender but y it is loading the page again and hitting that particular textbox when button is clicked.
    Wednesday, January 14, 2015 6:22 AM
  • Please post your html markup to check, it is normal for a button click (if it is a server side one) to reload the page unless UpdatePanel control is used. 

    Fouad Roumieh

    Wednesday, January 14, 2015 8:07 AM
  • My  Html  Code:

    When i click the imgbtnEdit function,OnClick functionality of imgbtnEdit  is performed and  then it hits to page load after successful imgbtnEdit function.

    the Page load is fired and then below textbox(txtReqDelDates) is fired automatically.when i comment the calender extender the page load is not hitting, but i need a calender extender as that is the requirement.

    There is no events  called in page load but then textbox text change event is getting fired after edit button click

    <asp:ImageButton ID="imgbtnEdit"
                                            runat="server" AlternateText="Edit"
                                            Enabled="false" CausesValidation="false" onmouseout="removehightlight(this.id)"
                                            onmouseover="hightlight(this.id)"
                                            ImageUrl="Images/edit_dis.png"
                                            title="Edit" ToolTip="Edit" OnClick="imgbtnEdit_Click" />

    <asp:TextBox ID="txtReqDelDates" runat="server" CssClass="toheadertextbox" CausesValidation="false" AutoPostBack="true" OnTextChanged="txtReqDelDate_TextChanged" />

     <cc1:CalendarExtender ID="calReqDelDates" runat="server" TargetControlID="txtReqDelDates"
                                            Format="MM/dd/yyyy">
                                        </cc1:CalendarExtender>
                                <asp:RequiredFieldValidator ID="rfvtxtReqDelDates" runat="server" ErrorMessage="Required"
                                    ForeColor="Red" ControlToValidate="txtReqDelDates" Display="None">
                                </asp:RequiredFieldValidator>



    • Edited by Bhagghu Wednesday, January 14, 2015 9:49 AM
    Wednesday, January 14, 2015 9:40 AM
  • It is normal when you click the imgbtnEdit to reload the page since it is a server side control that will perform a postback. 

    I've tried your code without the CalendarExtender and it did reload the page after chaning the text in textbox

    You mentioned:

    There is no events  called in page load but then textbox text change event is getting fired after edit button click

    How did you figure out this? Try to put a breakpoint into the txtReqDelDate_TextChanged and you will notice it is not fired on each page load?


    Fouad Roumieh

    Wednesday, January 14, 2015 10:26 AM
  • I know that button will perform the postback event,i used a breakpoint and confirmed after button performing its operation( imgbtnEdit_Click ),why it is again hitting to pageload  and calling the calender extender associated textbox event(txtReqDelDate_TextChanged)? when i remove the calender extender its not hitting the page load after button click event ( imgbtnEdit_Click ) and textbox is not triggered

    It is not after changing the textbox event hitting to page load but  imgbutton fires the page load after its  imgbtnEdit_Click operation  then  text change event(txtReqDelDate_TextChanged) is called.

    Wednesday, January 14, 2015 11:29 AM
  • do you have your image Url ImageUrl="Images/edit_dis.png" exists within your project and is it showing on your button. I've found that this was causing the double postback to happen. check it and let me know. If you change the ImageButton to Button you will see the diff.

    Also check any other missing images on the page or the master page


    Fouad Roumieh


    • Edited by Fouad Roumieh Wednesday, January 14, 2015 12:02 PM
    • Proposed as answer by Fouad Roumieh Thursday, January 15, 2015 8:24 AM
    Wednesday, January 14, 2015 12:00 PM
  • Hi Bhagghu,

    For questions related to ASP.NET use the ASP.NET forum     
    You should get more, better and faster answers on the other forum.  Thanks, ahead of time.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Just Karl Monday, February 2, 2015 11:11 PM
    Thursday, January 15, 2015 1:50 AM