0

I have situation where I'm opening a modal window using javascript i.e "download.aspx", On this aspx file I have a textbox to input ID and based upon this ID I query server and then download and XLS file from a location.

I'm using Ajax on my parent window .

Every thing goes fine , but when I do Response.Transmit("~/filename.xls");

Also I'm registring the Javascipt with "RegisterClientScriptBlock()" or RegisterStartupScript()

I'm getting follwing error

Sys.WebForms.PageRequestManagerServerErrorException: The script tag registered for type 'ASP.downloadxls_aspx' and key 'TicketNotExist' has invalid characters outside of the script tags: alert('Recipient does not exist:'). Only properly formatted script tags can be registered.

ghimireniraj
  • 397
  • 1
  • 5
sandeep
  • 25
  • 3
  • Can you edit your post to include the full line of code that calls `RegisterClientScriptBlock()`? – gilly3 Jul 22 '11 at 17:39

2 Answers2

0

have you tried to do a Response.Redirect("~/filename.xls") ?

Felipe Oriani
  • 37,948
  • 19
  • 131
  • 194
  • When I keep the button control inside the update panel then I recieve this error, "Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed." but If move the button outside the update panel, – sandeep Jul 22 '11 at 17:48
0

Call RegisterClientScriptBlock passing true as the final parameter, indicating that you are passing script without script tags and you want the ScriptManager to add them for you. Eg:

scriptMgr.RegisterClientScriptBlock(this.GetType(), "TicketNotExist",
    "alert('Recipient does not exist:');", true);
gilly3
  • 87,962
  • 25
  • 144
  • 176
  • yes but why this doesn't work with ajax, I have a button which is in update panel, on click of this button I'm registring this javascript – sandeep Jul 22 '11 at 18:03
  • @Sandeep - it seems like it should work just fine with AJAX. See this post: [RegisterClientScriptBlock within AJAX method call](http://stackoverflow.com/questions/297081/registerclientscriptblock-within-ajax-method-call/297291#297291). Note that he is using `true` in his call. – gilly3 Jul 22 '11 at 18:54