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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

change content type back to text/html

Thread ID:

Created:

Updated:

Platform:

Replies:

66757 Aug 2,2007 05:29 AM UTC Dec 27,2007 06:31 AM UTC ASP.NET Web Forms (Classic) 5
loading
Tags: XlsIO
Linda
Asked On August 2, 2007 05:29 AM UTC

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();


Melba Winshia [Syncfusion]
Replied On 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

Linda
Replied On 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

Linda
Replied On 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


Chris
Replied On 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?

Fathima Shalini P [Syncfusion]
Replied On 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



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;