locked
Writing HTML programmatically into a page using VB RRS feed

  • Question

  • User1764167293 posted

    How do I write HTML programmatically into a page from a code page in VB?

    Do I have to use Response.Write as in Classic ASP or is there a control I can write the HTML to?

    Thanking you in anticipation.

    Roger

     

     

     

    Tuesday, December 2, 2008 9:29 AM

Answers

  • User-319574463 posted

     Instead of

    <div id="Div1>

    try

    <div runat="server" id="Div1">

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 2, 2008 11:01 PM

All replies

  • User-319574463 posted

     You can write the HTML to the InnerHtml property of many controls.

    e.g. for

      <td runat="server" id="tddReplaceMe">TO BE REPLACED</td>

    In your code:

     tddReplaceMe.InnerHtml = "<b><i>Hello</i> World!</b>

    and on the running form your will see 

    Hello World!

    Tuesday, December 2, 2008 10:11 AM
  • User1764167293 posted

    Thanks for this.  It works fine.

     Now I need to programmatically write to a page HTML and controls.  For example:

    <div id="Div1> 

     <div>

        <asp:WebPartZone ID="WebPartZone1" runat="server"></asp:WebPartZone>

    </div>

    <div>

        <asp:WebPartZone ID="WebPartZone2" runat="server"></asp:WebPartZone>

    </div>

     </div>

    When I put Div1.innerhtml = all the code above, the div's are rendered put the zones are not.

     I'm trying to programmatically construct a web parts page that my customer can design and then populate.

     How do I do this?

     Your help would be much appreciated.

     Roger

    Tuesday, December 2, 2008 6:44 PM
  • User-319574463 posted

     Instead of

    <div id="Div1>

    try

    <div runat="server" id="Div1">

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 2, 2008 11:01 PM