change web form content type programmatically

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • andy

    #1

    change web form content type programmatically

    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="def ault.aspx.cs"
    inherits="xmlpo rtal.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.ContentTyp e="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>...<HT ML> 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

    #2
    Re: change web form content type programmaticall y

    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" <andy@mit.edu > wrote in message
    news:uNWdeRMSDH A.212@TK2MSFTNG P10.phx.gbl...[color=blue]
    > 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="def ault.aspx.cs"
    > inherits="xmlpo rtal.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.ContentTyp e="Text/Xml".....but got an error.....as it could NOT[/color]
    display[color=blue]
    > xml using the given stylesheet.
    >
    > Please suggest a way in which I could REMOVE/DEACTIVATE all the
    > <DOCTYPE>...<HT ML> elements (override them) and display the xml on the[/color]
    page[color=blue]
    > instead by using the xml Page CONTENT TYPE.
    >
    > Thanks a lot.
    > Andy
    > IESL, MIT
    >
    >[/color]


    Comment

    • David Banister

      #3
      Re: change web form content type programmaticall y

      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" <andy@mit.edu > wrote in message
      news:uNWdeRMSDH A.212@TK2MSFTNG P10.phx.gbl...[color=blue]
      > 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="def ault.aspx.cs"
      > inherits="xmlpo rtal.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.ContentTyp e="Text/Xml".....but got an error.....as it could NOT[/color]
      display[color=blue]
      > xml using the given stylesheet.
      >
      > Please suggest a way in which I could REMOVE/DEACTIVATE all the
      > <DOCTYPE>...<HT ML> elements (override them) and display the xml on the[/color]
      page[color=blue]
      > instead by using the xml Page CONTENT TYPE.
      >
      > Thanks a lot.
      > Andy
      > IESL, MIT
      >
      >[/color]


      Comment

      Working...