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>
Cineno28
  • 889
  • 1
  • 22
  • 41

1 Answers1

1

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

YazX
  • 444
  • 4
  • 12
  • 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 05 '15 at 01: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: http://stackoverflow.com/questions/1758240/how-do-i-make-a-textbox-postback-on-keyup – YazX Apr 05 '15 at 01:22