c# - How to call javascript function in item template when using gridview -


I am trying to call a JavaScript function which will set the foreground and backcolor control of the control when the control is over

but this function is not growing

   gt;')" & gt; & Lt;% # Eval ("ColorCode")% & gt; & Lt; / Div & gt; & Lt; / ItemTemplate & gt;  

This is my javascript

  function invert caller (sender, backcore) {alert ('hi'); // warning (backColor.toString ()); // if (backcoller! = '') {// // sender.css ('background-color', backcore); // backColor = backColor.substr (1, 6); // foreColor = numberToHex (255 - parseInt (backColor.substr (0, 2), 16)) / + numberHohex (255 - parseInt (backclosure.SUBTT (2, 2), 16)) // + numothex (255 - parsiat) (Backcoller. Subert (4, 2), 16)); // sender.css ('color', '#' + foreclose)}}  

You can do this immediately after the div if the element has a way to find it, such as ID or CSS class. Div will produce a unique ID for each item in a server control archive.

  & gt; Itemmetlet & gt; & Lt; Div runat = "server" id = "dummy" & gt; & Lt;% # Eval ("ColorCode")% & gt; & Lt; / Div & gt; & Lt; Script & gt; InvertColor ('<% = dummy.ClientID%>', '& lt;% # Eval ("ColorCode")%> & gt;'); & Lt; / Script & gt; & Lt; / ItemTemplate & gt;  

Here I have changed one parameter to string instead of an object. Inside the invertColor you can use the id string to get the context of the element, though you look fit.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -