We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

change content type back to text/html

I have a form where user selects information from a dropdown to display on the spreadsheet. The form has an asp:button control and the page posts back to itself and executes the button event handler method. In here, I do some validation. If there is a problem with what the user selected, I display an error message in an asp:label control on the same page. Now, when they modify the choices to something that is ok and hit the button again, it does the same postback, going through the validation and then I display the dialog box to open or save the excel file. The problem is that my original error message is still showing on the page even though I have cleared it out in pre render and set the label visible property to false. I believe this is because the content-type gets changed to ms/excel so the response never gets back to the aspx page with text/html. Is there a way to preserve the original http response so that the page can finish before the excel dialog box comes up? I think I need to do something with the third parameter, Response, but not sure what to do.

I'm using:
workbook.SaveAs ("Report.xls",ExcelSaveType.SaveAsXLS,
Response, ExcelDownloadType.PromptDialog);

excelEngine.ThrowNotSavedOnDestroy = false;
excelEngine.Dispose();


5 Replies

MW Melba Winshia Syncfusion Team August 3, 2007 12:04 PM UTC

Hi Linda,

Thank you for your interest in Essential XlsIO.

I am able to see the issue that you have mentioned here. But this can be solved by setting the AutoPostBack property of Dropdownlist to True.

Please refer the sample in the below link which illustrates the above.

http://websamples.syncfusion.com/samples/XlsIO.Web/4.4.0.51/F66757/main.htm

In the above sample if you select four, error message will be displayed and if you select some other value other than four dialogue box will be displayed.

Please try this and let me know if this helps.

Thanks,
Melba


LI Linda August 7, 2007 04:11 PM UTC

Thank you Melba for your quick response. That's a good solution but unfortunately I have multiple dropdowns on the page so autopostback isn't an option for me. There is also a textbox that could have invalid data and cause and error to be written. Do you have any other suggestions? I thought adding an onClientClick to the button and through javascript forcing a submit so it would do the post first but that doesn't work either. I'm stumped on this one.
Thank you


LI Linda August 7, 2007 04:31 PM UTC

Hi Melba,
Right after I sent my message, I found a way to get this to work. On the button control I added an OnClientClick="clearerror();"
Then I added this javascript function:
function clearerror()
{
if (document.getElementById('<%=lblMessage.ClientID %>') != null)
{
var x = document.getElementById('<%=lblMessage.ClientID %>');
x.style.display = 'none';
}
}

Thanks so much for your previous input. Much appreciated.
Linda



CH Chris October 3, 2007 07:52 PM UTC

I have a similar problem, but the onclient solution didn't work for me. My page inherits from another page and once it opens the the saveas dialog the response doesnt return to the page.
Any suggestions?


FS Fathima Shalini P Syncfusion Team December 27, 2007 06:31 AM UTC

Hi Chris,

Sorry for delay in responding.

If your intention is to open the excel file in another window, please use 'PromptDialog' property of ExcelDownloadType enumeration.

The following code snippet illustrates this.


workbook.SaveAs("Sample1.xls",Response,ExcelDownloadType.PromptDialog);


Please find the modified sample in the following location.

http://websamples.syncfusion.com/samples/XlsIO.Web/6.1.0.34/66757_Updated/main.htm

If I have misunderstood your requirement, could you please explain me in detail, so that I can work in depth and try to send a better solution?

Regards,
Fathima



Loader.
Live Chat Icon For mobile
Up arrow icon