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. Calling Sub Routine From Dynamic Link Button

Calling Sub Routine From Dynamic Link Button

Scheduled Pinned Locked Moved ASP.NET
question
6 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.
  • N Offline
    N Offline
    naveedmazhar
    wrote on last edited by
    #1

    Assalam-O-Alaikum! I have created dynamic link buttons. How can I call an "onCommand" sub routine on clicking any of the link buttons? Take care. Allah Hafiz

    C 1 Reply Last reply
    0
    • N naveedmazhar

      Assalam-O-Alaikum! I have created dynamic link buttons. How can I call an "onCommand" sub routine on clicking any of the link buttons? Take care. Allah Hafiz

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      By assigning an event to thier click handler, and creating the buttons in the LoadViewState method so that the events are not lost. Christian Graus - Microsoft MVP - C++

      A 1 Reply Last reply
      0
      • C Christian Graus

        By assigning an event to thier click handler, and creating the buttons in the LoadViewState method so that the events are not lost. Christian Graus - Microsoft MVP - C++

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        Can you please tell me how to do it? This is my code. *** Start - Code to create dynamic linkbuttons *** Dim Var_Loop Dim Var_Lbn As LinkButton For Var_Loop = 1 To 10 Var_Lbn = New LinkButton Var_Lbn.ID = "Lbn_" & Var_Loop Var_Lbn.Text = Var_Loop Var_Lbn.CommandArgument = CStr(Var_Loop - 1) Var_Lbn.CommandName = "a" & Var_Loop Me.Page.FindControl("Phr_Test").Controls.Add(Var_Lbn) 'Phr_Test is the place holder Next *** End - Code to create dynamic linkbuttons *** Now I want to call an onsubmit sub routine, how can I do this?

        C 1 Reply Last reply
        0
        • A Anonymous

          Can you please tell me how to do it? This is my code. *** Start - Code to create dynamic linkbuttons *** Dim Var_Loop Dim Var_Lbn As LinkButton For Var_Loop = 1 To 10 Var_Lbn = New LinkButton Var_Lbn.ID = "Lbn_" & Var_Loop Var_Lbn.Text = Var_Loop Var_Lbn.CommandArgument = CStr(Var_Loop - 1) Var_Lbn.CommandName = "a" & Var_Loop Me.Page.FindControl("Phr_Test").Controls.Add(Var_Lbn) 'Phr_Test is the place holder Next *** End - Code to create dynamic linkbuttons *** Now I want to call an onsubmit sub routine, how can I do this?

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Inside the loop: AddHandler Var_Lbn.Click, AddressOf MyClickHandler where MyClickHandler is a local function that has the signature void MyClickHandler object , EventArgs Now, you need to call this code in LoadViewState, as I said, or the click events will be lost. Christian Graus - Microsoft MVP - C++

          A 1 Reply Last reply
          0
          • C Christian Graus

            Inside the loop: AddHandler Var_Lbn.Click, AddressOf MyClickHandler where MyClickHandler is a local function that has the signature void MyClickHandler object , EventArgs Now, you need to call this code in LoadViewState, as I said, or the click events will be lost. Christian Graus - Microsoft MVP - C++

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            I did not succeed in doing this. Can you guide me in detail?

            C 1 Reply Last reply
            0
            • A Anonymous

              I did not succeed in doing this. Can you guide me in detail?

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              You need to overload the LoadViewStateMethod, and create your buttons there. Did you do that ? A simple test is to create a text box as well, and then in Page Load check if it retains it's value in the codebehind. If not, then your controls are still failing to be part of the control tree when viewstate is restored. Christian Graus - Microsoft MVP - C++

              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