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. webControls?

webControls?

Scheduled Pinned Locked Moved ASP.NET
csharphtmlasp-netvisual-studiohelp
2 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.
  • S Offline
    S Offline
    Snowjim
    wrote on last edited by
    #1

    Hey I have made a WebControl it is a meny that displays a header and if a button is hit then it will show the content in a tabel below the header here is the code that generates the html: private StringBuilder buildTop() { StringBuilder tmpSB = new StringBuilder(); tmpSB.Append(""); //tmpSB.Append(" ");//MainMenu tmpSB.Append(""); tmpSB.Append(""); tmpSB.Append(""); tmpSB.Append(""); tmpSB.Append(""); tmpSB.Append(" "); tmpSB.Append(mainTitle); tmpSB.Append(" "); //WHEN THIS IAMGE IS HIT THEN IS SHOLD SET THE Collapsed TO FALSE tmpSB.Append("![](pictures/main_menu/collaps_down.jpg)"); tmpSB.Append(" "); //tmpSB.Append(" "); return tmpSB; } private StringBuilder buildBottom() { StringBuilder tmpSB = new StringBuilder(); if(!Collapsed) { //tmpSB.Append(""); tmpSB.Append(" "); tmpSB.Append(" "); tmpSB.Append(MenuLinks.ToString()); tmpSB.Append(" "); tmpSB.Append(" "); //tmpSB.Append(""); } tmpSB.Append(""); return tmpSB; } protected override void Render(HtmlTextWriter output) { output.Write(buildTop().ToString() + buildBottom().ToString()); } this is working well :) But no i need to add a button to the top of the header, and if this button is pressed then it will dispplay the content. The PROBLEM: I dont understand how to add a image with onclick or what ever that will rais a event in my WebControl? When the image is hit then is shold rais an event that sets Collapse the oposite way false/true There is now way to see the webcontrol as i see the regular main asp.net projekt so i cant add controls by using the VS gui.

    B 1 Reply Last reply
    0
    • S Snowjim

      Hey I have made a WebControl it is a meny that displays a header and if a button is hit then it will show the content in a tabel below the header here is the code that generates the html: private StringBuilder buildTop() { StringBuilder tmpSB = new StringBuilder(); tmpSB.Append(""); //tmpSB.Append(" ");//MainMenu tmpSB.Append(""); tmpSB.Append(""); tmpSB.Append(""); tmpSB.Append(""); tmpSB.Append(""); tmpSB.Append(" "); tmpSB.Append(mainTitle); tmpSB.Append(" "); //WHEN THIS IAMGE IS HIT THEN IS SHOLD SET THE Collapsed TO FALSE tmpSB.Append("![](pictures/main_menu/collaps_down.jpg)"); tmpSB.Append(" "); //tmpSB.Append(" "); return tmpSB; } private StringBuilder buildBottom() { StringBuilder tmpSB = new StringBuilder(); if(!Collapsed) { //tmpSB.Append(""); tmpSB.Append(" "); tmpSB.Append(" "); tmpSB.Append(MenuLinks.ToString()); tmpSB.Append(" "); tmpSB.Append(" "); //tmpSB.Append(""); } tmpSB.Append(""); return tmpSB; } protected override void Render(HtmlTextWriter output) { output.Write(buildTop().ToString() + buildBottom().ToString()); } this is working well :) But no i need to add a button to the top of the header, and if this button is pressed then it will dispplay the content. The PROBLEM: I dont understand how to add a image with onclick or what ever that will rais a event in my WebControl? When the image is hit then is shold rais an event that sets Collapse the oposite way false/true There is now way to see the webcontrol as i see the regular main asp.net projekt so i cant add controls by using the VS gui.

      B Offline
      B Offline
      Brian M C
      wrote on last edited by
      #2

      You need to create a "Composite Control" in order to add an ImageButton web control to your custom control. You'll need to override the "CreateChildControls" protected method of the WebControl parent and add the ImageButton control to your control's "ControlCollection". Here's an example... private ImageButton myImage; protected override void CreateChildControls() { this.myImage = new ImageButton(); this.myImage.ID = "myImage"; this.myImage.ImageUrl = "Images/myImage.gif"; this.Controls.Add( myImage ); } In your render method you just call this.myImage.Render( output ); and the control will be rendered to the page. HTH, -BC

      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