change web form content type programmatically

Discussion in 'ASP .Net' started by andy, Jul 12, 2003.

  1. andy

    andy Guest

    I have user controls(.ascx) programmed to function as modules on the same
    page - default.aspx.
    As you would be well aware, default.aspx has the normal html stuff:-

    <%@ Page language="c#" codebehind="default.aspx.cs"
    inherits="xmlportal.read" autoeventwireup="false"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>.....</HEAD>
    <BODY>......</BODY>
    </HTML>

    --------------------------------------------------------------
    Now, here's my problem:-
    I want to change the ContentType of this page to "text/Xml" based on a
    condition in an ascx.cs codebehind.......i tried doing it with
    Page.ContentType="Text/Xml".....but got an error.....as it could NOT display
    xml using the given stylesheet.

    Please suggest a way in which I could REMOVE/DEACTIVATE all the
    <DOCTYPE>...<HTML> elements (override them) and display the xml on the page
    instead by using the xml Page CONTENT TYPE.

    Thanks a lot.
    Andy
    IESL, MIT
     
    andy, Jul 12, 2003
    #1
    1. Advertising

  2. I had to write a similar page, but my page actually handed back a gif image.
    If the page is always xml, just remove all the html from the page and remove
    your controls and everything. In the page load method set your content type
    just like you were, then override the render method and in the render method
    write the xml to the response stream directly. If you have any questions
    about that email me.

    Hope that helps,
    David
    "andy" <> wrote in message
    news:...
    > I have user controls(.ascx) programmed to function as modules on the same
    > page - default.aspx.
    > As you would be well aware, default.aspx has the normal html stuff:-
    >
    > <%@ Page language="c#" codebehind="default.aspx.cs"
    > inherits="xmlportal.read" autoeventwireup="false"%>
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > <HTML>
    > <HEAD>.....</HEAD>
    > <BODY>......</BODY>
    > </HTML>
    >
    > --------------------------------------------------------------
    > Now, here's my problem:-
    > I want to change the ContentType of this page to "text/Xml" based on a
    > condition in an ascx.cs codebehind.......i tried doing it with
    > Page.ContentType="Text/Xml".....but got an error.....as it could NOT

    display
    > xml using the given stylesheet.
    >
    > Please suggest a way in which I could REMOVE/DEACTIVATE all the
    > <DOCTYPE>...<HTML> elements (override them) and display the xml on the

    page
    > instead by using the xml Page CONTENT TYPE.
    >
    > Thanks a lot.
    > Andy
    > IESL, MIT
    >
    >
     
    David Banister, Jul 15, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hazz
    Replies:
    6
    Views:
    50,028
    SkyUCHC
    Jun 9, 2010
  2. Stanimir Stamenkov
    Replies:
    2
    Views:
    788
    Stanimir Stamenkov
    Oct 25, 2005
  3. Guan
    Replies:
    5
    Views:
    846
  4. Nathan Sokalski
    Replies:
    5
    Views:
    1,049
    Nathan Sokalski
    May 10, 2008
  5. Nathan Sokalski

    Programmatically adding a css style to a web content form

    Nathan Sokalski, May 5, 2008, in forum: ASP .Net Web Controls
    Replies:
    5
    Views:
    277
    Nathan Sokalski
    May 10, 2008
Loading...

Share This Page