Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: Literal Control and Onclick?

Reply
Thread Tools

Re: Literal Control and Onclick?

 
 
Mike Prager
Guest
Posts: n/a
 
      10-14-2003
Natty,

Sorry to bug you again. For some reason, the event handler does not get
raised when the linkbutton is clicked. Anything in particulat I should look
for?

Thx

Mike

"Natty Gur" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> There is no problem to create LinkButton dynamically and add an event
> handler. You just need to create event handler function and on page_load
> to add the controls and attach them to the event handler using AddHanler
> :
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> for (int i=0; i< 10; i++)
> {
> LinkButton olb = new LinkButton();
> olb.ID = "oLinkButton" + Convert.ToString (i);
> olb.Text = "attachment " + Convert.ToString (i);
> olb.CommandArgument = "file_ID or Location";
> olb.Visible = true;
> olb.Click += new EventHandler ( MyLinkButtonHandler);
> // VB - AddHandler olb.Click, AddressOf MyLinkButtonHandler
> this.Panel1.Controls.Add (olb);
> }
> }
>
> private void MyLinkButtonHandler(object sender, System.EventArgs e)
> {
> string clickButton = ((LinkButton)sender).ID;
> }
>
> HTH
>
> Natty Gur[MVP]
> Phone Numbers:
> Office: +972-(0)9-7740261
> Fax: +972-(0)9-7740261
> Mobile: +972-(0)58-888377
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What's the Difference between an asp:Literal control and an asp:Localize control? netcodedevil@gmail.com ASP .Net Web Controls 0 09-26-2007 11:12 AM
What's wrong with rpc-literal? Why use doc-literal? Anonieko Ramos ASP .Net Web Services 0 09-27-2004 09:06 AM
apply CSS on literal control? Jk ASP .Net 1 05-03-2004 05:23 PM
Literal Control with IFrame text, trying to remove from page without screen corruption NeilG ASP .Net 0 01-21-2004 10:49 AM
Rendering literal and serveral controls nested in web control at design time Stephen Miller ASP .Net Building Controls 1 01-02-2004 01:26 AM



Advertisments