c# - jQuery code working on Chrome and Mozilla web browser but not on Internet Explorer -


i have following code on aspx file:

<asp:gridview id="gridview1"  runat="server" showfooter="true"   autogeneratecolumns="false" >    <columns>             <asp:templatefield>               <itemtemplate> <asp:linkbutton id="button1" runat="server" text="active" onclientclick="return  confirmmessage(this);" />              </itemtemplate>     </columns> </asp:gridview> 

i have following jquery/client side code

function confirmmessage(obj) { if ($(obj).attr("text")=="active") { return confirm("convert active inactive"); } else { return confirm("convert inactive active"); } } 

the above mentioned code working fine on mozilla , chrome browswer in case of internet explorer , it's executing 2nd block i.e.

return confirm("convert inactive active"); 

help appreciated.

your problem related string comparison differences between different browsers, differences in text-from-dom generation mechanics. have tried see under debugger (such ie9 developer tools/scripting tab), returns $(obj).attr("text") under ie?

furthermore, approach of comparing texts not highly reliable anyway (e.g. fail after change in text of linkbutton). advise rely on either classes or different link buttons instead, example:

  1. use following markup linkbutton: (notice cssclass property):

    <asp:linkbutton id="button1" runat="server" text="active"  onclientclick="return confirmmessage(this);" cssclass="button-activate" /> 
  2. then use following javascript:

    function confirmmessage(obj) {      if ($(obj).is(".button-activate")) {           return confirm("convert active inactive");      } else {           return confirm("convert inactive active");      } } 

when button not 'activate' anymore 'deactivate', put other cssclass value linkbutton.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -