Results 1 to 7 of 7
  1. #1
    Lounger
    Join Date
    May 2006
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    New Window, form content on button click? (vb.net)

    I thought I'd post this one since it is sort of a weird situation that might merit a weird solution.
    Here's the scenario:
    I'm making a page with a simple form to compose an e-mail message... basically a text box for your name and a web-based text editor for the message field.
    Once this form is completed and the user hits "send", the information in the form is wrapped in an html template and sent to a specified address as an html e-mail.

    I've done this before, it's not the problem.

    The problem is that one of the requirements is a "preview" button that pulls up the html e-mail in a new window before sending. Opening a new window is no big deal, but of course that requires a URL...
    I have done systems before that changed the response headers of a link to give a csv file or something similar... the same could probably be done to send "assembled" html content... but I am not sure how to accomplish this ALSO in a new window.

    So as the subject sort of implies, I need to be able to click a preview button, and pop up a new window that displays information from the previous form. I could do one or the other, but I haven't came up with a way to accomplish both. A LinkButton may work easier, but I would prefer that it actually looks/behaves like a button!

    I appreciate any help, thanks.

  2. #2
    Lounger
    Join Date
    May 2006
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: New Window, form content on button click? (vb.net)

    So far I can create the templated e-mail "preview" and display it in the same window... which is ok... but it's not what I'm after, since the user would have to click "back" and then submit their message...

    using Preview.attributes.add("onclick", "window.open('something')") opens a new window, sure enough, but of course it opens the "something"... it would be nice if I knew how to manipulate the response of this page like I can the page with the form on it...
    i.e.
    response.clear()
    response.addheader(etc)
    response.write(blah)

    obviously this only affects the original page, not the one that I am popping up by clicking the button. There should be some way to do this, yes?

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: New Window, form content on button click? (vb.

    Can you open the "about:blank" page?

  4. #4
    Lounger
    Join Date
    May 2006
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: New Window, form content on button click? (vb.

    Well, I could try it (though as far as I know that is strictly an ie/windows thing...)
    but my point is that no matter what url I would give it to try an open, I would still have no control over the content of that page beyond telling it to open something else...
    my intention is to open a new window with "synthesized" html, that is, html that is generated based on the form and does not come from a file on the server.
    using window.open() I am so far unable to use such trickery except on the original (non-popup) window. So... for example, I could pop up a new window with, say, google, when the button is pressed, and then it would follow my vb script code to write the response by making the headers and filling the content etc, but that this vb code would edit the response of the *original* page, and not the one that was opened by window.open... if that makes any sense.

    If I am not describing this well enough (which could be a possibility), do let me know and I will post the page as an example.

  5. #5
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: New Window, form content on button click? (vb.

    Your comment about opening a window with "synthesized" html sounds like the best option. That's essentially how web applications work - build the html on the fly from server-side elements and data values.

  6. #6
    Lounger
    Join Date
    May 2006
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: New Window, form content on button click? (vb.

    However I am so far unable to make this synthesized content appear in a popup window, only in the current window... arg! [img]/forums/images/smilies/smile.gif[/img]
    The content is assembled with my vb code, but a new windows is opened using javascript... is there a way that I can include a vb script function as an argument to the javascript window.open() method? Perhaps if this vb script function returned the appropriate code? Just a stab in the dark but that's how I envision it working... something along the lines of:

    PreviewButton.Attributes.add("onclick", "window.open(MakePage())")

    where MakePage is a function that returns the synthesized preview page code... as opposed to sticking a URL in there? Is this possible or am I just making things up at this point...?

    I think I am pretty close but am not quite sure how to finish it all up. I have read a few other posts online that suggest creating new windows like this, but they say nothing past providing a URL to provide the page content.

  7. #7
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: New Window, form content on button click? (vb.

    Just to be clear, is this a windows app or a web app? I've seen things to suggest both, but I would guess you're talking about a web app. And if that's the case, then my previous comment would not make much sense (I was thinking Windows at the time).

    Are you using session state in this application? If so, you can write a method that uses a postback to store the contents of the editor in session, then opens a popup when the page loads. The popup window (preview) would read the value from session and you're in business.

    If you're not using session state, you could use the data store of your choice (i.e. database) and use a timestamp/userId as a key of some sort. There are quite a few ways to skin this cat... <img src=/S/catty.gif border=0 alt=catty width=19 height=18>

Posting Permissions

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