Results 1 to 4 of 4

Thread: clicking twice for dialog box [RESOLVED]

  1. #1

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    clicking twice for dialog box [RESOLVED]

    I'm using this code on the click event to open a print dialog box..
    The problem I'm having is, you have to click the button twice before the dialog box will show....Any suggestions?

    Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
    btnPrint.Attributes.Add("onclick", "javaScript:window.print()")
    End Sub
    Last edited by EyeTalion; Nov 18th, 2002 at 11:28 AM.

  2. #2
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    you have to do it twice cuz you that attribute isn't added until you click it one. After you click it once then it's added, now you have to click it again then it works. Add the attribute in the Page_Load:
    VB Code:
    1. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.     PrintDialog.Attributes.Add("onClick", "window.print()")
    3. End Sub
    Question though, why use a server side control for this, why not just use a regular ol' button? just curious

  3. #3

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    thanks pvb, that worked.

    If I used an HTML button, would that be quicker becasue I wouldn't have to postback?

  4. #4
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    not sure if it would be noticably faster but it would save you an unneccessary postback.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width