javascript - Disable click event over GridView ASP.NET -


i'm working on asp.net gridview made clickable method:

protected void onrowdatabound(object sender, system.web.ui.webcontrols.gridviewroweventargs e)     {         gridview gr = (gridview)sender;         if (e.row.rowtype == datacontrolrowtype.datarow)         {             e.row.attributes["onmouseover"] = "this.style.cursor='hand';this.style.background='#3260a0';;this.style.color='white'";             e.row.attributes["onmouseout"]  = "this.style.textdecoration='none';this.style.background='white';this.style.color='black'";             e.row.attributes["onclick"]     = page.clientscript.getpostbackclienthyperlink(rh, "select$" + e.row.rowindex);             e.row.attributes["style"]       = "cursor:pointer";         }                } 

now

i want disable functionality when press button

, don't know how to. tried using enable = false, aparently doesn't affect script , keeps allowing me click on grid again. want when press button disable grid, stop mouse on animation , onclick immediatly, haven´t found proper way.

here code of gridview in case:

<asp:gridview id="rh" runat ="server" margin-right ="auto"           margin-left="auto" onselectedindexchanged="rh_selectedindexchanged"          onrowdatabound ="onrowdatabound" cssclass ="gridview" horizontalalign="center"           allowpaging="true" onpageindexchanging="onpageindexchanging" pagesize="5">             </asp:gridview> 

let have button disable:

<asp:button id="btn" runat="server" onclick="btn_click" text="disable click" /> 

then on button click can remove onclick evented added dynamically:

 protected void btn_click(object sender, eventargs e)         {             foreach (gridviewrow row in rh.rows)             {                 row.attributes.remove("onclick");             }         } 

if need onclick event again add attribute button click:

 protected void btn2_click(object sender, eventargs e)         {             foreach (gridviewrow row in rh.rows)             {                 row.attributes["onclick"] = page.clientscript.getpostbackclienthyperlink(rh, "select$" + row.rowindex);             }         } 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -