1

I have a textbox in an updatepanel, set to autopostback. It's working fine when I change the text.

The problem is, that I'd like to allow users to clear the box content as well. So it should also post back on a blank box. But after deleting the text, it's not posting.

I have a validation control, but it's only for the max character count, and allows zero. I've tried it without that validation and it's still not posting back on an empty textbox.

What do I need to change?

<asp:UpdatePanel ID="UpdatePanelPhone" runat="server" UpdateMode="Conditional">
                                        <ContentTemplate>
                                            <label class="col-md-4 col-xs-5 control-label">Phone Number</label>
                                            <div class="col-md-8 col-xs-7"> 

                                                <asp:RegularExpressionValidator ID="txtPhoneRegularExpressionValidator" runat="server"    
                                                    ControlToValidate="txtPhone"
                                                    Text="Maximum 50 characters"
                                                    ValidationExpression="^.{0,50}$"
                                                    Display="None"
                                                    CssClass="label label-danger label-form" />

                                                <div class="input-group">
                                                    <span class="input-group-addon"><span class="fa fa-phone"></span></span>
                                                    <asp:TextBox ID="txtPhone" runat="server" CssClass="form-control validate[maxSize[50]]" AutoPostBack="True" OnTextChanged="txtPhone_TextChanged" CausesValidation="True"/>

                                                </div>                                            
                                            </div>
                                        </ContentTemplate>
                                        <Triggers>
                                            <asp:AsyncPostBackTrigger ControlID ="txtPhone" EventName ="TextChanged" />
                                        </Triggers>
                                    </asp:UpdatePanel>
1
  • Why are you using an update panel to implement autocomplete? There are better ways.
    – mason
    Apr 5, 2015 at 4:01

1 Answer 1

1

Change UpdateMode="Conditional" to UpdateMode="Always"

2
  • Thank you for your response. Unfortunately, I tried this, but it's still not posting. I'm not sure what else it could be
    – Cineno28
    Apr 5, 2015 at 1:19
  • i was afraid of that, then your only option is to add javascript code when the onkeyup is raised to check if the textbox is empty, if so then you need to call the _postback() function for your textbox control. look at this example: stackoverflow.com/questions/1758240/…
    – YazX
    Apr 5, 2015 at 1:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.