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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to output a web control so that it can be postbacked from the page?

How to output a web control so that it can be postbacked from the page?

Scheduled Pinned Locked Moved ASP.NET
htmltutorialquestion
3 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.
  • B Offline
    B Offline
    Billypon
    wrote on last edited by
    #1

    How to output a web control so that it can be postbacked from the page? I write the code like this: LinkButton btnTest = new LinkButton(); btnTest.Text = "Test"; btnTest.Click += new EventHandler(btnTest_Click); StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); btnTest.RenderControl(htw); lblTest.Text = sw.ToString(); Now the control could be outputed by HTML code, but it cannot be postbacked from the page. It be outputed like a normal text, not a LinkButton. I want it can be clicked, and raise the click event. So, what can I do for it?

    R 1 Reply Last reply
    0
    • B Billypon

      How to output a web control so that it can be postbacked from the page? I write the code like this: LinkButton btnTest = new LinkButton(); btnTest.Text = "Test"; btnTest.Click += new EventHandler(btnTest_Click); StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); btnTest.RenderControl(htw); lblTest.Text = sw.ToString(); Now the control could be outputed by HTML code, but it cannot be postbacked from the page. It be outputed like a normal text, not a LinkButton. I want it can be clicked, and raise the click event. So, what can I do for it?

      R Offline
      R Offline
      raj code
      wrote on last edited by
      #2

      Hi, btnTest.PostbackUrl="specify to which u want to postback"; I hope this will suffice ur requirement. Happy Programming.

      B 1 Reply Last reply
      0
      • R raj code

        Hi, btnTest.PostbackUrl="specify to which u want to postback"; I hope this will suffice ur requirement. Happy Programming.

        B Offline
        B Offline
        Billypon
        wrote on last edited by
        #3

        No, it doesn't it! At last, the server output the HTML's code like Test. So the LinkButton cannot be clicked!!!

        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