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. button in Repeater item

button in Repeater item

Scheduled Pinned Locked Moved ASP.NET
comhelpannouncement
12 Posts 3 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.
  • R Offline
    R Offline
    RongNK
    wrote on last edited by
    #1

    When i work width tab ajax control, and in one tab, I have a Repeater:

    and in protected void rp1_ItemCommand(object source, RepeaterCommandEventArgs e) method, i add a button and it's event: Button btn = new Button(); btn.Text = "Update"; btn.Click += new EventHandler(btn_Click); ((Repeater)source).Items[0].Controls.Add(btn); void btn_Click(object sender, EventArgs e) { Response.Redirect("http://google.com"); } but when click on update button, event do not raise(btn do not drive click event). please help me ! Sorry for my english. :)

    E C 4 Replies Last reply
    0
    • R RongNK

      When i work width tab ajax control, and in one tab, I have a Repeater:

      and in protected void rp1_ItemCommand(object source, RepeaterCommandEventArgs e) method, i add a button and it's event: Button btn = new Button(); btn.Text = "Update"; btn.Click += new EventHandler(btn_Click); ((Repeater)source).Items[0].Controls.Add(btn); void btn_Click(object sender, EventArgs e) { Response.Redirect("http://google.com"); } but when click on update button, event do not raise(btn do not drive click event). please help me ! Sorry for my english. :)

      E Offline
      E Offline
      Eaverae
      wrote on last edited by
      #2

      It seems that you do not give your button object an ID, so it cannot decide which button to use. Maybe try that and see if the result is better? Good luck.

      "My personality is not represented by my hometown."

      R 2 Replies Last reply
      0
      • E Eaverae

        It seems that you do not give your button object an ID, so it cannot decide which button to use. Maybe try that and see if the result is better? Good luck.

        "My personality is not represented by my hometown."

        R Offline
        R Offline
        RongNK
        wrote on last edited by
        #3

        btn.ID = "Cmd3"; Thank. I did it, but not work.

        E 1 Reply Last reply
        0
        • R RongNK

          btn.ID = "Cmd3"; Thank. I did it, but not work.

          E Offline
          E Offline
          Eaverae
          wrote on last edited by
          #4

          Does your code work when you place the repeater outside of the AJAX control?

          "My personality is not represented by my hometown."

          R 2 Replies Last reply
          0
          • E Eaverae

            It seems that you do not give your button object an ID, so it cannot decide which button to use. Maybe try that and see if the result is better? Good luck.

            "My personality is not represented by my hometown."

            R Offline
            R Offline
            RongNK
            wrote on last edited by
            #5

            I did it, but not work :( Thank !

            1 Reply Last reply
            0
            • E Eaverae

              Does your code work when you place the repeater outside of the AJAX control?

              "My personality is not represented by my hometown."

              R Offline
              R Offline
              RongNK
              wrote on last edited by
              #6

              Same, it not work. Please give me a solution :)

              1 Reply Last reply
              0
              • E Eaverae

                Does your code work when you place the repeater outside of the AJAX control?

                "My personality is not represented by my hometown."

                R Offline
                R Offline
                RongNK
                wrote on last edited by
                #7

                when i use PlaceHolder instead of Repeater, the problem continue :confused:

                1 Reply Last reply
                0
                • R RongNK

                  When i work width tab ajax control, and in one tab, I have a Repeater:

                  and in protected void rp1_ItemCommand(object source, RepeaterCommandEventArgs e) method, i add a button and it's event: Button btn = new Button(); btn.Text = "Update"; btn.Click += new EventHandler(btn_Click); ((Repeater)source).Items[0].Controls.Add(btn); void btn_Click(object sender, EventArgs e) { Response.Redirect("http://google.com"); } but when click on update button, event do not raise(btn do not drive click event). please help me ! Sorry for my english. :)

                  E Offline
                  E Offline
                  Eaverae
                  wrote on last edited by
                  #8

                  Please run your page in debug mode, and set a breakpoint at the rp1_ItemCommand method. Then you can see what is causing this problem.

                  "My personality is not represented by my hometown."

                  R 1 Reply Last reply
                  0
                  • E Eaverae

                    Please run your page in debug mode, and set a breakpoint at the rp1_ItemCommand method. Then you can see what is causing this problem.

                    "My personality is not represented by my hometown."

                    R Offline
                    R Offline
                    RongNK
                    wrote on last edited by
                    #9

                    Properties of btn: OnClientClick "" string PostBackUrl "" string UseSubmitBehavior true bool Why OnClientClick "" string :confused:

                    1 Reply Last reply
                    0
                    • R RongNK

                      When i work width tab ajax control, and in one tab, I have a Repeater:

                      and in protected void rp1_ItemCommand(object source, RepeaterCommandEventArgs e) method, i add a button and it's event: Button btn = new Button(); btn.Text = "Update"; btn.Click += new EventHandler(btn_Click); ((Repeater)source).Items[0].Controls.Add(btn); void btn_Click(object sender, EventArgs e) { Response.Redirect("http://google.com"); } but when click on update button, event do not raise(btn do not drive click event). please help me ! Sorry for my english. :)

                      E Offline
                      E Offline
                      Eaverae
                      wrote on last edited by
                      #10

                      Please read some documentation on ASP.Net first; Really try to take your time. Learning to program requires a lot patience and time. Then if you have questions, try to not post a question in 15 seconds, but really think how others will read it. So, give an explanation that is logical and describes the problem. Once I have more details on your issue I will be glad to help. Good luck!

                      "My personality is not represented by my hometown."

                      R 1 Reply Last reply
                      0
                      • E Eaverae

                        Please read some documentation on ASP.Net first; Really try to take your time. Learning to program requires a lot patience and time. Then if you have questions, try to not post a question in 15 seconds, but really think how others will read it. So, give an explanation that is logical and describes the problem. Once I have more details on your issue I will be glad to help. Good luck!

                        "My personality is not represented by my hometown."

                        R Offline
                        R Offline
                        RongNK
                        wrote on last edited by
                        #11

                        Thank :)

                        1 Reply Last reply
                        0
                        • R RongNK

                          When i work width tab ajax control, and in one tab, I have a Repeater:

                          and in protected void rp1_ItemCommand(object source, RepeaterCommandEventArgs e) method, i add a button and it's event: Button btn = new Button(); btn.Text = "Update"; btn.Click += new EventHandler(btn_Click); ((Repeater)source).Items[0].Controls.Add(btn); void btn_Click(object sender, EventArgs e) { Response.Redirect("http://google.com"); } but when click on update button, event do not raise(btn do not drive click event). please help me ! Sorry for my english. :)

                          C Offline
                          C Offline
                          cramteke
                          wrote on last edited by
                          #12

                          since you are dynamically adding control so the controls are not saved. try adding the controls when the page post back aging and it should work then

                          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