Saturday, 15 January 2011

javascript - Modifying embedded hyperlink in asp.net repeater -


I am using an asp.net repeater and data from SQL to data tie I am here. I want to modify the hyperlink on the client side based on the DataRow . There may be several other hyperlinks in the table, but I have to process one in the other column alone. What is the best way to do that? Any code sample is highly appreciated.

  & lt; Table border = "0" cellpadding = "2" cellspacing = "0" width = "100%" id = "myTable" & gt; & Lt; TR & gt; & Lt; Td align = "left" & gt; Id & lt; / Td> & Lt; Td align = "left" & gt; DESCRIPTION & lt; / Td> & Lt; Td> STATUS & lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; 10 & lt; / TD & gt; & Lt; TD & gt; & Lt; Span style = "color: red; font-weight: bold" & gt; The server is down & lt; / Span & gt; & Lt; A href = "/ admin.aspx" & gt; Here & lt; / A & gt; To continue. & Lt; / TD & gt; & Lt; Td> No response & lt; / Td> & Lt; / TR & gt; & Lt; / Table & gt;  

You can use the following jQuery to change all the links in the second column of 2 seconds Line:

  $ (document) .ready (function () {$ ('# myTable tr: nth-child (2) td: nth-child (2) a'). Function () {var someValue = '/ 2'; $ (this) .prop ('href', some value $ $ (this) .prop ('href'));});});  

This is the point from where you can get some code of that code, you can get your code anyway & lt; Asp: repeater & gt; to add it to the output & lt; Td> Such a data may be placed in the form, such as:

Repeater Output

  ... & lt; Td data-id = "2" & gt; & Lt; Span style = "color: red; font-weight: bold" & gt; The server is down & lt; / Span & gt; & Lt; A href = "/ admin.aspx" & gt; Here & lt; / A & gt; To continue. & Lt; / TD & gt; ...  

JS

  var someValue = '/' + $ (this). Parent (). Data ('id');  

No comments:

Post a Comment