Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Reset render method flag ????

Reset render method flag ????

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelpquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tee
    wrote on last edited by
    #1

    For some reason, I need to call base.Render (HtmlTextWriter writer) for serveral times, but with different writer. However, I got this error - "Can only have one form tag for a Page". It seems that the ASP.NET system has a flag determining how many times we call the render method. So I am here to ask - Is there a way to reset the render method, so I can call it many times i want ??

    S 1 Reply Last reply
    0
    • T Tee

      For some reason, I need to call base.Render (HtmlTextWriter writer) for serveral times, but with different writer. However, I got this error - "Can only have one form tag for a Page". It seems that the ASP.NET system has a flag determining how many times we call the render method. So I am here to ask - Is there a way to reset the render method, so I can call it many times i want ??

      S Offline
      S Offline
      Syed Abdul Khader
      wrote on last edited by
      #2

      There is no such flag. If you post the code, I can see what the problem is.

      T 1 Reply Last reply
      0
      • S Syed Abdul Khader

        There is no such flag. If you post the code, I can see what the problem is.

        T Offline
        T Offline
        Tee
        wrote on last edited by
        #3

        protected override void Render(HtmlTextWriter writer) { foreach (string email in emailList) { StringBuilder _buffer = new StringBuilder (); StringWriter swa = new StringWriter (_buffer); HtmlTextWriter htmlWriter = new HtmlTextWriter (swa); /* Change some content in the Page */ ... base.Render (htmlWriter); MailMessage mail = new MailMessage (); mail.To = email; mail.Body = _buffer.ToString (); mail.BodyFormat = MailFormat.Html; SmtpMail.SmtpServer = "192.168.0.1"; SmtpMail.Send (mail); htmlWriter.Close (); } } Here is the code that get problem. The base.Render will not run twice !!! PS. Here is some aritcle talking about the flag http://msdn.microsoft.com/msdnmag/issues/03/05/CuttingEdge/default.aspx[^]

        S 1 Reply Last reply
        0
        • T Tee

          protected override void Render(HtmlTextWriter writer) { foreach (string email in emailList) { StringBuilder _buffer = new StringBuilder (); StringWriter swa = new StringWriter (_buffer); HtmlTextWriter htmlWriter = new HtmlTextWriter (swa); /* Change some content in the Page */ ... base.Render (htmlWriter); MailMessage mail = new MailMessage (); mail.To = email; mail.Body = _buffer.ToString (); mail.BodyFormat = MailFormat.Html; SmtpMail.SmtpServer = "192.168.0.1"; SmtpMail.Send (mail); htmlWriter.Close (); } } Here is the code that get problem. The base.Render will not run twice !!! PS. Here is some aritcle talking about the flag http://msdn.microsoft.com/msdnmag/issues/03/05/CuttingEdge/default.aspx[^]

          S Offline
          S Offline
          Syed Abdul Khader
          wrote on last edited by
          #4

          When I test with the code I got the same error. I dont know the problem. In this case you can workaround this, if have understand your code correctly. I hope you want to email the page content to a set of email (the same content). Why u r getting the html to be sent in the email in the loop. Get the content before loop as string and then send it to all. Now the n time (loop) rendering reduced to 2 times (one for email and one for page rendering). Instead of calling base.Render for page rendering, you just use Response.Redirect to recreate the page. Hope this will help.

          T 1 Reply Last reply
          0
          • S Syed Abdul Khader

            When I test with the code I got the same error. I dont know the problem. In this case you can workaround this, if have understand your code correctly. I hope you want to email the page content to a set of email (the same content). Why u r getting the html to be sent in the email in the loop. Get the content before loop as string and then send it to all. Now the n time (loop) rendering reduced to 2 times (one for email and one for page rendering). Instead of calling base.Render for page rendering, you just use Response.Redirect to recreate the page. Hope this will help.

            T Offline
            T Offline
            Tee
            wrote on last edited by
            #5

            How about the email content that sent to everyone is not exactly the same ? Does it mean that you need to render everytimes you change he content ?!!!

            S 1 Reply Last reply
            0
            • T Tee

              How about the email content that sent to everyone is not exactly the same ? Does it mean that you need to render everytimes you change he content ?!!!

              S Offline
              S Offline
              Syed Abdul Khader
              wrote on last edited by
              #6

              You are sending the page content as email for many ids. Thats what I understand from ur code. If you want to change the content, change the content of the html string in the loop. Hope I get your question correctly.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups