0

I am unable to make the controls visible off properly. All gets visible off IN visibleFalse() function but chkToU text is still remained visible but checkbox gets invisible. And button did not change its text to "OK"

--HTML
<script>
    function visibleFalse() {
        $("#<%= lblMessage.ClientID %>").css('display', 'none');
        $("#<%= chkToU.ClientID %>").css('display', 'none');
        $("#<%= btnToU.ClientID %>").css('display', 'none');
        $("#<%= btnOK.ClientID %>").val('OK');
    }
</script>

<div style="padding-top: 5px">
    <asp:CheckBox ID="chkToU" Style="margin-left: 12px;" runat="server" AutoPostBack="true"
            Text="&nbsp;I agree to the whole contents of the" OnCheckedChanged="chkToU_CheckedChanged"/>
    <asp:LinkButton ID="btnToU" runat="server" 
        OnClientClick="return visibleFalse();"
        UseSubmitBehavior="false" onclick="btnToU_Click">ToU
    </asp:LinkButton>
</div>

<asp:UpdatePanel ID="UpdatePanel2" runat="server">
    <ContentTemplate>
        <asp:LinkButton ID="btnOK" OnClick="btnOK_Click" Width="60px" Text="Cancel" 
            CssClass="btn btn-success btn-sm" runat="server">
        </asp:LinkButton>
        <br />
        <asp:Label ID="lblMessage" ForeColor="Red" runat="server" Text=""></asp:Label>
    </ContentTemplate>
</asp:UpdatePanel>

--CODE BEHIND       
protected void btnToU_Click(object sender, EventArgs e)
{
    if (DownloadFile())
    {
        //bellow code not working -- its redirecting to default but file download not work
        //it also doesnt make visible false in code behind due to response object
        //Response.Redirect("../Default.aspx");
        //chkToU.Visible = false;
        //lblMessage.Visible = false;
        //btnToU.Visible = false;
        //btnOK.Text = "OK";
    }
}

private bool DownloadFile()
{
    fileName = "TermsAndConditions.pdf";
    Response.Clear();
    Response.Buffer = true;
    Response.ContentType = "application/pdf";
    Response.AddHeader("content-disposition", "attachment;filename=" + fileName);     // to open file prompt Box open or Save file         
    Response.Charset = "";
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.TransmitFile(Server.MapPath("../Files/TermsAndConditions.pdf"));
    Response.Flush();
    lblMessage.Visible = false;
    return true;
}

Please help me. Thanks

Raja
  • 131
  • 2
  • 16
  • Anybody here to help me please... – Raja Jul 04 '16 at 09:43
  • See http://stackoverflow.com/questions/4025288/update-page-after-file-download why you cannot download a file AND update the page content. – VDWWD Jul 05 '16 at 13:48

0 Answers0