Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Getting StartedGetting StartedEnable / Disable DNN Button in JavasScriptEnable / Disable DNN Button in JavasScript
Previous
 
Next
New Post
1/17/2011 12:12 PM
 

There is no substitute for a good understanding of why things happen!

Using dnn.dom.getByTag returns a collection of elements by tag.  Turns out an asp:LinkCommand is translated to an HTML link “<a>”.  Hence this command button is not in the <input> tag collection but the <a> link collection.

It’s important to note the the asp:LinkCommand control must have a “name” attribute to be accessible:

<asp:LinkButton CssClass="CommandButton" ID="cmdReport" runat="server" name="cmdReport" Enabled="true"

                text="Confirm Selected Customers" OnClick="cmdReport_Click"></asp:LinkButton>

In JavaScript to get a list of links on the page using the DNN client API do the following:

        // Tags can be: form, body, select, textarea, input, Script, head, a, etc
        var linkList = dnn.dom.getByTagName("a");        // HtmlCollection
        var theButton = linkList["cmdReport"];         

       // This should disable the link but it doesn’t
      theButton.disabled = true;

 
New Post
1/22/2011 4:52 PM
 
I have finally found a solution using JQuery.  I still think there has to be a better way of getting a page element then going through a list of elements by tag name.  Somehow there should be a way to get the DNN hashed name of the element via a dnn dom function.

<script type="text/javascript">
     $(document).ready(function () {

           // Do stuff when DOM is ready

         // Initialy hide the cmdReport Button
         var linkList = dnn.dom.getByTagName("a");        // HtmlCollection
         var theLink = linkList["cmdReport"];
         var linkJQName = "#" + theLink.id;
         $(linkJQName).hide();
     });

function radGridCustomerPool_setReportLink(sender, eventArgs)
     {
         var linkList   = dnn.dom.getByTagName("a");        // HtmlCollection
         var theLink    = linkList["cmdReport"];
         var linkJQName = "#" + theLink.id;

         var selected = eventArgs.get_tableView().get_selectedItems();
         if (selected.length > 0)
         {
             $(linkJQName).show();
         }
         else
         {
             $(linkJQName).hide();
         }
     }
</script>


<asp:LinkButton type="button" CssClass="CommandButton" ID="cmdReport" runat="server" name="cmdReport" Enabled="true"
                text="Confirm Selected Customers" OnClick="cmdReport_Click"></asp:LinkButton>



 
New Post
1/22/2011 4:52 PM
 
I have finally found a solution using JQuery.  I still think there has to be a better way of getting a page element then going through a list of elements by tag name.  Somehow there should be a way to get the DNN hashed name of the element via a dnn dom function.

<script type="text/javascript">
     $(document).ready(function () {

           // Do stuff when DOM is ready

         // Initialy hide the cmdReport Button
         var linkList = dnn.dom.getByTagName("a");        // HtmlCollection
         var theLink = linkList["cmdReport"];
         var linkJQName = "#" + theLink.id;
         $(linkJQName).hide();
     });

function radGridCustomerPool_setReportLink(sender, eventArgs)
     {
         var linkList   = dnn.dom.getByTagName("a");        // HtmlCollection
         var theLink    = linkList["cmdReport"];
         var linkJQName = "#" + theLink.id;

         var selected = eventArgs.get_tableView().get_selectedItems();
         if (selected.length > 0)
         {
             $(linkJQName).show();
         }
         else
         {
             $(linkJQName).hide();
         }
     }
</script>


<asp:LinkButton type="button" CssClass="CommandButton" ID="cmdReport" runat="server" name="cmdReport" Enabled="true"
                text="Confirm Selected Customers" OnClick="cmdReport_Click"></asp:LinkButton>



 
New Post
1/24/2011 10:25 AM
 
I think I've beat this to death.  In the end the problem I'm having is that Firefox will not disable an ASP:LinkButton yet in IE setting the disabled attribute to true/false works fine.  Go figure!  So to achieve cross browser support the best way to disable an ASP:LinkButton is to remove and add back its "href" attribute via jQuery script.


         // Initialy hide the cmdReport Button
         var linkList = dnn.dom.getByTagName("a");     // HtmlCollection
         var dnnLink = linkList["cmdReport"];          // The link DNN object
         var dnnName = "#" + dnnLink.id;               // The hashed dnn html ID
         var jqLink = $(dnnName);                      // The link jQuery object
 
         // To disable an ASP:LinkButton remove the href attribute.
         // Save it and put it back to enable again.
         // These do not work in Firefox but do in IE: jqLink.attr("disabled", true);  jqLink.attr("enabled", false);
         var linkHref = jqLink.attr("href");
         jqLink.removeAttr("href");         // Disable
         jqLink.attrib("href", linkHref);   // Enable
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Getting StartedGetting StartedEnable / Disable DNN Button in JavasScriptEnable / Disable DNN Button in JavasScript


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out