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