Click here to Skip to main content
16,016,759 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I need to open pdf file in a new window, show the open save cancel dialog box and then close the window when the user chooses an option. Is there any way to do this.
If anybody know this please help me.

Thanks.
Posted
Comments
ZeeroC00l 14-May-11 1:53am    
Please try to keep title of your question short and up to the point. You can explain your questions in details in the question section
Jayanthi-SE 14-May-11 3:36am    
ok thanks

hello there
you can use the resultmsgbox

VB
Public Function resultmsgbox(ByVal StrMsg As String) As Object

        Dim ans As MsgBoxResult
        ans = MsgBox(StrMsg, MsgBoxStyle.YesNoCancel + MsgBoxStyle.Information, "Title Text")
        Return ans

    End Function

and on the buttons click event whose click will open the Dialog Box :

SQL
Dim res As MsgBoxResult = clslog.resultmsgbox("Message To Show on the MsgBox")

            If res = MsgBoxResult.Yes Then
                // if yes will pressed execute this code
                End If              
            else if res = MsgBoxResult.No Then
                // if no will pressed execute this code
                end if

            else if res = MsgBoxResult.Cancel Then
                // if cancel will pressed execute this code
                end if


End If

to open The PDF read the following articles :
http://www.codeguru.com/forum/archive/index.php/t-322006.html[^]
or
http://www.justskins.com/forums/viewing-adobe-pdf-documents-16704.html[^]
or
http://visualbasic.about.com/od/quicktips/qt/disppdf.htm[^]
if you want to create a custom message box read :
http://www.java2s.com/Code/CSharp/GUI-Windows-Form/MessageBoxOptions.htm[^]

best regards.
 
Share this answer
 
v2
Comments
Jayanthi-SE 14-May-11 3:39am    
hi thanks.
VB
Dim Str As String = "FolderName/Pdf FileName.pdf"

        If File.Exists(Server.MapPath(Str)) Then


            Dim objFi As IO.FileInfo = New IO.FileInfo(Server.MapPath(Str))

            HttpContext.Current.Response.Clear()

            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + objFi.Name)

            HttpContext.Current.Response.Charset = ""

            HttpContext.Current.Response.AddHeader("Content-Length", objFi.Length.ToString())

            HttpContext.Current.Response.ContentType = "application/octet-stream"

            HttpContext.Current.Response.WriteFile(objFi.FullName)

            HttpContext.Current.Response.End()

            CloseWindow()
        Else
            Response.Write("<script>alert('Server is busy.Try again ')</script>")

        End If
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900