Pop up a message before prompting to Save Word

k89mmk

Member
Joined
Jun 7, 2005
Messages
6
Location
n/a
Programming Experience
3-5
Good morning,

I'm not sure if I'm posting this in the right place, but hopefully someone will be able to help me out! I'm developing a web application using asp.net.

Long story short: I want to pop up an alert box and, when the user clicks 'OK', prompt them to save a word document. Right now I can pop up the alert box, or I can prompt them to save a word document, but I can not do both.

Here's the long story in case you want more details: When a user clicks save, I'm checking the database to see if the timestamp has changed since the entry was loaded. If it hasn't, the entry is saved. If it has, the entry is not saved.

If the entry is not saved, I want to pop up a message explaining that someone else has changed this entry since it was loaded, so please reload and try again. But I don't want all the users changes to be lost, so after this message is displayed, I want to allow the user to save the changes as a word document.

Simple enough, right?!!! haha

Here is one of the scripts I've tried for the pop up (I've also tried putting the alert in a Reponse.Write, and using RegisterClientScriptBlock)
VB.NET:
[size=1]Message = Message.Replace("'", "\'")
Message = Message.Replace(Convert.ToChar(10), "\n")
Message = Message.Replace(Convert.ToChar(13), "")
[/size][size=1][color=#0000ff]Dim[/color][/size][size=1] alertScript [/size][size=1][color=#0000ff]As[/color][/size][size=1][color=#0000ff]String[/color][/size][size=1] = "<script language=JavaScript>"
alertScript += "alert('" + Message + "');"
alertScript += "</script" + ">"
[/size][size=1][color=#0000ff]If[/color][/size][size=1][color=#0000ff]Not[/color][/size][size=1] (IsStartupScriptRegistered("alert")) [/size][size=1][color=#0000ff]Then
[/color][/size][size=1]	RegisterStartupScript("alert", alertScript)
[/size][size=1][color=#0000ff]End[/color][/size][size=1][color=#0000ff]If
[/color][/size]

And here is the code I'm using for the Save To Word prompt
VB.NET:
[size=1]Response.AddHeader("Content-Disposition", "attachment;filename= SomeNiceName.doc")
Response.ContentType = "application/msword"
[/size][size=1][color=#008000]' send the file stream to the client , replacing symbols known to cause problems
[/color][/size][size=1]Response.Write(strFileData.Replace("•", "<li>").Replace(vbCrLf, "<br>").Replace("„", "<li>").Replace("’", "'").Replace("–", "-"))
Response.End()
[/size]

TIA!
 
Back
Top