Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8021649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:02:58+00:00 2026-06-04T22:02:58+00:00

I’m letting my users write their own HTML from my webpage. When they click

  • 0

I’m letting my users write their own HTML from my webpage.

When they click the preview button, my code behind needs access to controls on the page (and so I understand I can’t use a web method here).

It builds the HTML and saves it as a file on the server.

My question is:
Once the file has been made, I want to automatically open the file in a new window for the user to see their handy work.

I’m using vb.net, but happy to receive c# answers.

Thanks folks !
.
.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=–=-=-=-=-=-=–=-=-=–=-=-
Thank you very much Jan !!

I still have a slight problem though…
My code goes like this:

If fileExists Then
        Do Until fileExists = False
            tmpFormPreviewFileName = "Test" & GetRandomNumber() & ".html"
            tmpFormPreviewFilePath = Server.MapPath("~") & "Pages\FormPreviews\" & tmpFormPreviewFileName
            fileExists = My.Computer.FileSystem.FileExists(tmpFormPreviewFileName)
        Loop
    End If

    My.Computer.FileSystem.WriteAllText(tmpFormPreviewFilePath, strHTML, False)


    'Now open the file in a new window
    btnPreview.OnClientClick = String.Format("window.open('/Pages/FormPreviews/{0}', 'myPopup', 'width=400,height=500')", tmpFormPreviewFileName)

So, the problem is – I don’t know what the filename will be until after the user has clicked the preview button and the OnClientClick event won’t fire until the user clicks the button for the 2nd time (which of course creates another HTML file)

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=–=-=-=-=-=-=–=-=-=–=-=-=-=-=-=-=-=-=-=-=-=-
I’m still having problems getting the popup to work.
Here’s my code at the moment:

'create a JavaScript command for opening the file in popup window
    Dim strScript As String = String.Format("window.open('/Pages/FormPreviews/{0}, 'myPopup', 'width=400,height=500')", tmpFormPreviewFileName)

    'register the JavaScript to be executed when web page loads
    ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "openPopup", strScript, True)
    ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "ShowMsg", "javascript:alert('Test Msg');", True)

My “ShowMsg” fires succesfully, but the line above it (the popup code) doesn’t seem to work. Can you see what’s going wrong at all ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:03:00+00:00Added an answer on June 4, 2026 at 10:03 pm

    I think your missing a quote in your JavaScript (see below)

    Dim strScript As String = String.Format("window.open('/Pages/FormPreviews/{0}<-- here  
    

    Try this:

    Dim strScript As String = String.Format("window.open('/Pages/FormPreviews/{0}', 'myPopup', 'width=400,height=500')", tmpFormPreviewFileName)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have this code to decode numeric html entities to the UTF8 equivalent character.
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.