Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

I need help adding "onclick" event to anchor tag dynamically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pbd22 - 24 Oct 2007 14:38 GMT
Hi.

I am trying to add an "onclick" 'event to an
anchor tag and this is proving harder than
I imagined.

The anchor HAS NO ID. And, there will be tons of them on the page. So,
I cannot access it via FindControl.

the tag is nested as such:

<td></td><td><a href='#'>clicky</a></td><td></td>

My approach has been to muddle with RowDataBound but it isn't clear to
me how to do this.

Please help.
Thanks.

protected void vGridView_RowDataBound(object sender,
GridViewRowEventArgs e)
       {

           if (e.Row.RowType == DataControlRowType.DataRow)
           {

                   //
e.Row.Cells[1].Controls[0].Attributes.Add("onclick",
"alert(getRowText(this));return false;");

          }
       }
Eliyahu Goldin - 24 Oct 2007 14:49 GMT
Your code looks fine. Are you experiencing any problem?

Signature

Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net

> Hi.
>
[quoted text clipped - 28 lines]
>           }
>        }
pbd22 - 24 Oct 2007 16:03 GMT
On Oct 24, 9:49 am, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.org> wrote:
> Your code looks fine. Are you experiencing any problem?
>
[quoted text clipped - 35 lines]
> >           }
> >        }

Bruce -

Would you mind showing me how to add runat=server to the anchor tags
created in a ButtonField?

Thanks
pbd22 - 24 Oct 2007 16:13 GMT
> On Oct 24, 9:49 am, "Eliyahu Goldin"
>
[quoted text clipped - 49 lines]
>
> Thanks

I am having the same problem with your suggestion - I don't know how
to access the a tag to change its attributes.
I need to do this dynamically from the server but am a bit lost as to
how this is done. Would you mind illustrating
this?

I really appreciate it.

Thanks.
pbd22 - 24 Oct 2007 17:07 GMT
> > On Oct 24, 9:49 am, "Eliyahu Goldin"
>
[quoted text clipped - 59 lines]
>
> Thanks.

no takers?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.