Ajax and Json if value in textbox is editing not see the modify in c#

30 Views Asked by At

In my form I have insert a Panel with UpdateProgress and UpdatePanel

This Panel is update with Ajaxand Json

My problem is that when update the value on the TextBox ID="txman" in the database the edit is registered but when I return to the aspx page the change is not displayed.

To see the edit on the TextBox ID="txman" I have to close the browser and reopen the aspx page.

How to do resolve this?

My code below

<asp:UpdateProgress ID="UpdateProgress4" runat="server"
    AssociatedUpdatePanelID="UpdatePanel1">
    <ProgressTemplate>
        <div class="modal">
            <div class="center">
                <img alt="" src="/aspnet/img/831.gif" />
            </div>
        </div>
    </ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <div class="pure-g">
            <div class="pure-u-1 pure-u-md-1-3">
                <asp:TextBox ID="txman" runat="server" Height="200" TextMode="MultiLine" CssClass="pure-u-23-24"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ControlToValidate="txman"
                    SetFocusOnError="true" ErrorMessage="Required" Text=""
                    Display="None" ValidationGroup="ValidationSummary2"
                    CssClass="validation-summary-errors-one"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator Display="Dynamic"
                    ControlToValidate="txman"
                    ID="RegularExpressionValidator9"
                    ValidationExpression="^[\s\S]{0,2000}$"
                    runat="server" ErrorMessage="max 2000"
                    ValidationGroup="ValidationSummary2">
                </asp:RegularExpressionValidator>
            </div>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>
<div class="container">
   <asp:ImageButton ID="imgf" runat="server" ValidationGroup="ValidationSummary2"
   ImageUrl="/aspnet/Img/save_button.gif" OnClientClick="if (!confirm('Confirm?')) return false;" />
</div>
<asp:ValidationSummary ID="ValidationSummary2" ValidationGroup="ValidationSummary2" runat="server" ShowMessageBox="true"
   CssClass="validation-summary-errors" ShowSummary="false" />

    $(function () {
        $("[id*=imgf]").bind("click", function () {

            var qString = "?" + window.location.href.split("?")[1];
            var f = {};

                $.ajax({
                    type: "POST",
                    url: "Default.aspx/Save" + qString,
                    data: '{f: ' + JSON.stringify(f) + '}',
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",

                    ...
1

There are 1 best solutions below

1
Hamamelis On

Put this code in page load.

Now there will be no data in cache browser will try to get the page from the server.

 Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
 Response.Cache.SetCacheability(HttpCacheability.NoCache);
 Response.Cache.SetNoStore();