Dynamically creating a .js file to be included in response

Discussion in 'ASP .Net' started by Ron Vecchi, Oct 21, 2003.

  1. Ron Vecchi

    Ron Vecchi Guest

    I am creating a custom web control that uses an enum for a property
    If the property is set to inline then text is read from the embedded
    resource and sent to the browser in the aspx page as inline java script.
    If the property is set to Remote then the script tag set with the SRC
    attribute is displayed <script language="javascript"

    Is there a way to catch an incoming request from the browser (for the
    <script language="javascript" src="myJavaScript.js"></script>
    And then dynamically create the file before it returns a response to the
    browser that the file does not exsit

    Ron Vecchi, Oct 21, 2003
    1. Advertisements

  2. Hi,

    Sleight of hand: specify an aspx file in the SRC attribute of the SCRIPT tag
    and generate the script on the fly in this aspx file.
    Dmitriy Lapshin [C# / .NET MVP], Oct 21, 2003
    1. Advertisements

  3. Ron Vecchi

    Ron Vecchi Guest

    One problem with that is that now I would need to have an aspx file along
    with my custom control.
    I have recently caught notice of HttpHandlers but really don't know what
    they are or how to use them.

    Ron Vecchi, Oct 21, 2003
  4. Ron,

    In case of Http handlers I beleive you'll still have to have an additional
    handler file (don't remember its extension) - or at least modify the
    application's web.config file to register the handler.

    Dmitriy Lapshin [C# / .NET MVP]
    X-Unity Test Studio
    Bring the power of unit testing to VS .NET IDE

    Dmitriy Lapshin [C# / .NET MVP], Oct 22, 2003
  5. Hi Ron,

    Firstly I wan to thank Dmitriy for this great help in this issue.

    Based on my research and experience, we need not to create our own
    httphandler or httpmoudle in this case. As my opinion, since we know when
    the enum propery is equal to Remote,InLine or when it equal to another
    value, we can decide whether we need to generate the js file at that time
    on the fly.

    If I have misunderstood your concern, please feel free to let me know.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ┬ĘC www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jacob Yang [MSFT], Oct 22, 2003
  6. Ron Vecchi

    Ron Vecchi Guest

    Yes, It took me a little while to think through it but since the enum is
    known I basically check for it and then create a directory and the .js file
    on the server and render my control with the <Script> tag either with the
    src attribute pointed to the newly created file or with the tag and
    javascript all togeather on the page.

    Ron Vecchi, Oct 22, 2003
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.