Note that there are some explanatory texts on larger screens.

plurals
  1. POLink Button have some Problems
    primarykey
    data
    text
    <p>I have one ASP.NET application which includes one gridview. This gridview contains 4 template columns of checkboxes and 2 template columns of link buttons. If I click on the first checkbox, then both of the link buttons should be enabled, otherwise they should be in disabled mode. This functionality is working fine. But my problem is, at the time of form loading, it will check whether the first column is checked or not. If the checkbox is not checked, the link buttons will be in disabled mode. But after the checking of this checkbox, it will enabled, but there is no link to redirect. My code is shown below.</p> <pre><code> protected void DGDocuments_ItemDataBound(object sender, DataGridItemEventArgs e) { if (e.Item.ItemIndex == -1) return; BindCheckBox(e.Item, "chkRead"); BindCheckBox(e.Item, "chkCreate"); BindCheckBox(e.Item, "chkUpdate"); BindCheckBox(e.Item, "chkDelete"); CheckBox chkID = (CheckBox)e.Item.FindControl("chkRead"); if (!chkID.Checked) { LinkButton lnkPermission = (LinkButton)e.Item.FindControl("lnkFieldPermssion"); LinkButton lnkSetRules = (LinkButton)e.Item.FindControl("lnkAddRules"); lnkPermission.Enabled = false; lnkSetRules.Enabled = false; } } </code></pre> <p>In designer page: </p> <pre><code> &lt;asp:TemplateColumn HeaderText="Read" ItemStyle-HorizontalAlign="Center"&gt; &lt;ItemTemplate&gt; &lt;asp:CheckBox ID="chkRead" runat="server" Text='&lt;%# Eval("Read") %&gt;' onclick="javascript:EnablePermissoin(this,5,6);" /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateColumn&gt; &lt;asp:TemplateColumn HeaderText="Rules" ItemStyle-HorizontalAlign="Center" ItemStyle-Font-Bold="true"&gt; &lt;ItemTemplate&gt; &lt;asp:LinkButton ID="lnkAddRules" Text="Add Rules" runat="server" CommandName="cmdSetRules" /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateColumn&gt; &lt;asp:TemplateColumn HeaderText="Field Permission" ItemStyle-HorizontalAlign="Center" ItemStyle-Font-Bold="true"&gt; &lt;ItemTemplate&gt; &lt;asp:LinkButton ID="lnkFieldPermssion" Text="Set" runat="server" CommandName="cmdFieldPermission" /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateColumn&gt; </code></pre> <p>Javascript is:</p> <pre><code>function EnablePermissoin(chkB, cellNumber1, cellNumber2) { var IsChecked = chkB.checked; if (IsChecked) { var cell1 = chkB.parentElement.parentElement.cells[cellNumber1]; for (i = 0; i &lt; cell1.childNodes.length; i++) { if (cell1.childNodes[i].tagName == "A") { cell1.childNodes[i].disabled = false; } } var cell2 = chkB.parentElement.parentElement.cells[cellNumber2]; for (i = 0; i &lt; cell2.childNodes.length; i++) { if (cell2.childNodes[i].tagName == "A") { cell2.childNodes[i].disabled = false; } } } else { var cell1 = chkB.parentElement.parentElement.cells[cellNumber1]; for (i = 0; i &lt; cell1.childNodes.length; i++) { if (cell1.childNodes[i].tagName == "A") { cell1.childNodes[i].disabled = true; } } var cell2 = chkB.parentElement.parentElement.cells[cellNumber2]; for (i = 0; i &lt; cell2.childNodes.length; i++) { if (cell2.childNodes[i].tagName == "A") { cell2.childNodes[i].disabled = true; } } } } </code></pre> <p>This is the code obtained from view source of the browser, without disabling the link button on form loading:</p> <pre><code>&lt;td align="center" style="font-weight:bold;"&gt; &lt;a id="DGDocuments_ctl23_lnkAddRules" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&amp;quot;DGDocuments$ctl23$lnkAddRules&amp;quot;, &amp;quot;&amp;quot;, true, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, false, true))"&gt;Add Rules&lt;/a&gt; &lt;/td&gt;&lt;td align="center" style="font-weight:bold;"&gt; &lt;a id="DGDocuments_ctl23_lnkFieldPermssion" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&amp;quot;DGDocuments$ctl23$lnkFieldPermssion&amp;quot;, &amp;quot;&amp;quot;, true, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, false, true))"&gt;Set&lt;/a&gt; &lt;/td&gt; </code></pre> <p>If I disable the link button on loading, this will be the code obtained from the view source:</p> <pre><code>&lt;td align="center" style="font-weight:bold;"&gt; &lt;a id="DGDocuments_ctl23_lnkAddRules" disabled="disabled"&gt;Add Rules&lt;/a&gt; &lt;/td&gt;&lt;td align="center" style="font-weight:bold;"&gt; &lt;a id="DGDocuments_ctl23_lnkFieldPermssion" disabled="disabled"&gt;Set&lt;/a&gt; &lt;/td&gt; </code></pre> <p>Please help me to solve this. Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload