Hi I have written code to generate linkbuttons dynamically. Code: [CODE] Sub createlinkbutton(ByVal commandtext As String, ByVal Cmdarg As String, ByVal pane As Panel, ByVal count As Int32) Dim panela As Panel = New Panel panela.CssClass = "boxx" pane.Controls.Add(panela) Dim lbButton As LinkButton = New LinkButton lbButton.Text = commandtext lbButton.CommandName = commandtext lbButton.CommandArgument = Cmdarg AddHandler lbButton.Command, AddressOf Me.LinkButton_Command AddHandler lbButton.Click, AddressOf Me.LinkButton_Click panela.Controls.Add(lbButton) End Sub [/CODE] When I call to the above function from any where the button creates successfully and when i click the button Command Command event of linkbutton fires successfully. e.g for below All calls linkbuttons are created and works fine. Code: [SIZE=2]createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Loncdon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane1, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Londxon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane1, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Londosn"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane1, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Londons"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane1, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"kLondon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane1, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Ljondon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Lonndon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Lonndon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Londnon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane1, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Londonn"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane1, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Londonb"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"fLondon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Regiorn"[/COLOR][/SIZE][SIZE=2], Pane1, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Lodndon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Regiorn"[/COLOR][/SIZE][SIZE=2], Pane1, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Londdon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane1, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Londdon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane1, 12) [/SIZE] But when I call to function from within the loop(while or for) then buttons are created successfully. but the event handler doesn't work. e.g the linkbuttons created for below code doesn't fires event. Code: [SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] k = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] DT.Rows.Count createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"New Button2"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Regio345"[/COLOR][/SIZE][SIZE=2], Pane1, 12) [/SIZE][SIZE=2][COLOR=#0000ff]Next [/COLOR][/SIZE] while each time the parameters passed to function are different please help in this issue Thanks
Hi, Looks like the code can fail if the CSS being called is lost in the transaction. Have you tried using server directives for the CSS path? Additionally...If that is the problem and you are using Master Pages use this trick on the child pages: <%@ MasterType VirtualPath="~/yourdefault.master" %> Which points to the Master page that calls the CSS. Salute, Marka
Thanks for your reply. I don't understand what you are saying. If i call to the funciton from pageload event using code below Code: createlinkbutton([SIZE=2][COLOR=#800000]"Loncdon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane1, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Londxon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane1, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Londosn"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane1, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Londons"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane1, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"kLondon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane1, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Ljondon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Lonndon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Lonndon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Londnon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane1, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Londonn"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane1, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Londonb"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"fLondon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Regiorn"[/COLOR][/SIZE][SIZE=2], Pane1, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Lodndon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Regiorn"[/COLOR][/SIZE][SIZE=2], Pane1, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Londdon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane1, 12) createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]"Londdon"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane1, 12) [/SIZE] Linkbutton created using this code works fine. The command event fires successfully. but If i use the below code Code: [COLOR=#0000ff]For[/COLOR][SIZE=2] k = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] DT.Rows.Count createlinkbutton([/SIZE][SIZE=2][COLOR=#800000]DT.Rows(k)("Region")[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Region"[/COLOR][/SIZE][SIZE=2], Pane1, DT.Rows(0)("num")) [/SIZE][SIZE=2][COLOR=#0000ff]Next [/COLOR][/SIZE] Using this code The buttons created doesn't fires command event. Thanks