HighTechTalks DotNet Forums  

Problem with Dynamically Creating Link Buttons

ASP.net Building Controls microsoft.public.dotnet.framework.aspnet.buildingcontrols


Discuss Problem with Dynamically Creating Link Buttons in the ASP.net Building Controls forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default Problem with Dynamically Creating Link Buttons - 09-18-2003 , 12:02 PM






Hello,

This is my code behind code for dynamic link button creation:

strUrl = "<asp:LinkButton CommandName='Onet3_Cd'
onfiltered='LinkButton_Command' runat='server' " & _
"Text='" & rdrOnet3("ONET3_TITLE") & "'
CommandArgument='" & rdrOnet3("ONET3_CD") & "' id='lb"
& i & "'></asp:LinkButton>"

Dim ctrl As Control =
Page.ParseControl(strUrl.ToString())
plcCategory.Controls.Add(ctrl) ' place holder on html page

The link button shows up fine when I run this, but
when I click on the link, it doesn't take me to

Sub LinkButton_Command(ByVal sender As Object, ByVal e
As CommandEventArgs)

Dim strDesc As String
strDesc = sender.text
Response.Write(sender.text)
End Sub

I based my code on

http://msdn.microsoft.com/library/de...ref/html/frlr\
fsystemwebuiwebcontrolslinkbuttonclasscommandnamet opic.asp

The click works if I hard code the link button on the
html page, but if I create it dynamically, the click
does not take me to the above sub.

Do you know how to fix this?

Thanks,

Burak

Reply With Quote
  #2  
Old   
BK
 
Posts: n/a

Default Problem with Dynamically Creating Link Buttons - 09-18-2003 , 07:00 PM






Burak,
From what I understand, since you are creating the
imagebutton dynamically you have to make sure that you add
the imagebutton on every page load for your button_click
event to work.So make sure what ever code you are adding
to add the imagebutton dynamically is executed on every
page load.

Hope this helps
BK

Quote:
-----Original Message-----
Hello,

This is my code behind code for dynamic link button
creation:

strUrl = "<asp:LinkButton CommandName='Onet3_Cd'
onfiltered='LinkButton_Command' runat='server' " & _
"Text='" & rdrOnet3("ONET3_TITLE") & "'
CommandArgument='" & rdrOnet3("ONET3_CD") & "' id='lb"
& i & "'></asp:LinkButton>"

Dim ctrl As Control =
Page.ParseControl(strUrl.ToString())
plcCategory.Controls.Add(ctrl) ' place holder on
html page

The link button shows up fine when I run this, but
when I click on the link, it doesn't take me to

Sub LinkButton_Command(ByVal sender As Object, ByVal e
As CommandEventArgs)

Dim strDesc As String
strDesc = sender.text
Response.Write(sender.text)
End Sub

I based my code on

http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/cpref/html/frlr\
fsystemwebuiwebcontrolslinkbuttonclasscommandnamet opic.asp

The click works if I hard code the link button on the
html page, but if I create it dynamically, the click
does not take me to the above sub.

Do you know how to fix this?

Thanks,

Burak
.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.