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. Write onclick event for code behind file page

Write onclick event for code behind file page

Scheduled Pinned Locked Moved ASP.NET
4 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.
  • V Offline
    V Offline
    VK Link
    wrote on last edited by
    #1

    Hi, I have some dynamic radio buttons on my web page and want to write some code for an onclick event with in the code behind file page. Any ideas would be helpful! Thanks for your time, Vani

    W 1 Reply Last reply
    0
    • V VK Link

      Hi, I have some dynamic radio buttons on my web page and want to write some code for an onclick event with in the code behind file page. Any ideas would be helpful! Thanks for your time, Vani

      W Offline
      W Offline
      Wyxlwiis
      wrote on last edited by
      #2

      Well u can do it this way example public class WebForm10 : System.Web.UI.Page { protected System.Web.UI.WebControls.RadioButton rbtn1; protected System.Web.UI.WebControls.RadioButton rbtn2; private void Page_Load(object sender, System.EventArgs e) { if(!IsPostBack) { rbtn1.Attributes.Add("onclick","alert('rbtn1.Selected')"); rbtn2.Attributes.Add("onclick","alert('rbtn2.Selected')"); //OR Like this rbtn1.Attributes["onclick"] = "alert('rbtn1.Selected')"; rbtn2.Attributes["onclick"] = "alert('rbtn1.Selected')"; } } Wyx :cool:

      V 1 Reply Last reply
      0
      • W Wyxlwiis

        Well u can do it this way example public class WebForm10 : System.Web.UI.Page { protected System.Web.UI.WebControls.RadioButton rbtn1; protected System.Web.UI.WebControls.RadioButton rbtn2; private void Page_Load(object sender, System.EventArgs e) { if(!IsPostBack) { rbtn1.Attributes.Add("onclick","alert('rbtn1.Selected')"); rbtn2.Attributes.Add("onclick","alert('rbtn2.Selected')"); //OR Like this rbtn1.Attributes["onclick"] = "alert('rbtn1.Selected')"; rbtn2.Attributes["onclick"] = "alert('rbtn1.Selected')"; } } Wyx :cool:

        V Offline
        V Offline
        VK Link
        wrote on last edited by
        #3

        Awesome! The alert works! I was trying to set the back ground color for the radio button - tried something like rb.Backcolor.Blue - but it comes back with error message - since rb is defined as radio button it cannot be converted to string? Thanks.

        W 1 Reply Last reply
        0
        • V VK Link

          Awesome! The alert works! I was trying to set the back ground color for the radio button - tried something like rb.Backcolor.Blue - but it comes back with error message - since rb is defined as radio button it cannot be converted to string? Thanks.

          W Offline
          W Offline
          Wyxlwiis
          wrote on last edited by
          #4

          Well if its in C# the correct syntax will be rbtn1.BackColor = Color.Blue; Wyx

          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