Reputation: 11
hello everybody i am using c# .net in my webapplication. i have a method for export gridview data to excel name ExportToExcel(). in this method i use response.contenttype, response.clear(),response.write(),stringwriter,htmltextwriter methods. this method work fine and export data correctly. but when i write button1.visible = false above that method call then button does not unvisible. Means i write the following
button1.visible = false; // both not work on runtime panel1.visible = false; // ExportToExcel()
another problem is that after call ExportToExcel() method if i click on any button on my webpage then ExportToExcel() again call and shows dialog box to save and open excel file.
so please help me how to solve this problem I m unable to send code due to company rules so please help me
Thank to all in advance
Upvotes: 0
Views: 385
Reputation: 936
Your C# is rendering HTML elements and sending them to the client. HTML does not have a .visible property. You need to set correct HTML atributes or style rules before sending the element back to the client.
It sounds like you are calling ExportToExcel() after every postback. Have you checked that the you are only calling it when the ExportToExcel button is clicked?
Upvotes: 0