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/8/2011 5:25 PM
 
Does anyone know how to get a button from a DNN form so it may be enabled and disabled.  I have a javaScript that is called when a row in a grid control changes but can't seem to be able to locate the button.  I know the names have been hashed for the form and I can't access the button directly by its name.  I've tried:

<script type="text/javascript" language="Javascript">

    // Enable or disable the submit button if there are any rows selected
    function radGridCustomerPool_setReportButton(sender, eventArgs)
    {
        //       var row = eventArgs.get_itemIndexHierarchical()
        var selected = eventArgs.get_tableView().get_selectedItems()
//        var cmdReport = dnn.dom.getByTagName("cmdReport");
        var body = dnn.dom.getByTagName("body")[0];
        var form = dnn.dom.getByTagName("form")[0];
        var x = form.cmdReport;
        form);
        x);
//        cmdReport.disabled = (selected.length > 0)
   }

</script>
 
New Post
1/14/2011 4:21 PM
 
Any idea why I can get back an HTML Button but not a ASP:LinkCommand?


<input id="HTMLButton" type="button" value="button" />

<asp:LinkButton CssClass="CommandButton" ID="cmdReport" runat="server"
               text="Report" OnClick="cmdReport_Click" Enabled="false"></asp:LinkButton>



       var formList = dnn.dom.getByTagName("Form");               // HtmlCollection
        if (formList.length > 0)
        {
            var theForm      = formList.item(0);                 // HTMLFormElement
            var formElements = theForm.elements;                 // HTMLCollection

            var a = formElements.item("HtmlButton");   // Returns an HTMLInputElement object

            var b = formElements.item("cmdReport");    // Returns null
        }


 
New Post
1/16/2011 12:17 PM
 
I've inspected the form in Firebug and have noticed that the HTML button in my last post shows up but the 2 ASP:LinkCommand elements are strangely missing from the form elements.  This accounts for why I can't use the DNN Client API to gain access to them.  So now the question is why are they missing.   Is this an ASP thing or the interaction of DNN with ASP?


elements
    [input#__EVENTTARGET, input#__EVENTARGUMENT, input#__VIEWSTATE /wEPDwUL...ljqhRw==, 26 more...]
    input#__EVENTTARGET
    input#__EVENTARGUMENT
    input#__VIEWSTATE /wEPDwUL...ljqhRw==
    input#dnn_dnnSEARCH_txtSearchNew.SearchTextBox
    textarea#dnn_ctr385_View_txtName.style1ci
    textarea#dnn_ctr385_View_txtSCV.style2ci
    textarea#dnn_ctr385_View_txtContract.style2ci
    textarea#dnn_ctr385_View_txtDUNS.style2ci
    input#HTMLButton button
    input#dnn_ctr385_View_radGridCustomerPool_ctl00_ctl02_ctl01_selectedSelectCheckBox
    input.rgPageFirst
    input.rgPagePrev
    input.rgPageNext
    input.rgPageLast
    input#dnn_ctr385_View_radGridCustomerPool_ctl00_ctl03_ctl01_PageSizeComboBox_Input.rcbInput 10
    input#dnn_ctr385_View_radGridCustomerPool_ctl00_ctl03_ctl01_PageSizeComboBox_ClientState {"logEnt...d":true}
    input#dnn_ctr385_View_radGridCustomerPool_ctl00_ctl04_selectedSelectCheckBox
    input#dnn_ctr385_View_radGridCustomerPool_ctl00_ctl06_selectedSelectCheckBox
    input#dnn_ctr385_View_radGridCustomerPool_ctl00_ctl08_selectedSelectCheckBox
    input#dnn_ctr385_View_radGridCustomerPool_ctl00_ctl10_selectedSelectCheckBox
    input#dnn_ctr385_View_radGridCustomerPool_ctl00_ctl12_selectedSelectCheckBox
    input#dnn_ctr385_View_radGridCustomerPool_ctl00_ctl14_selectedSelectCheckBox
    input#dnn_ctr385_View_radGridCustomerPool_ctl00_ctl16_selectedSelectCheckBox
    input#dnn_ctr385_View_radGridCustomerPool_ctl00_ctl18_selectedSelectCheckBox
    input#dnn_ctr385_View_radGridCustomerPool_ctl00_ctl20_selectedSelectCheckBox
    input#dnn_ctr385_View_radGridCustomerPool_ctl00_ctl22_selectedSelectCheckBox
    input#dnn_ctr385_View_radGridCustomerPool_ClientState {"select...xes":[]}
    input#ScrollTop 468
    input#__dnnVariable {"__scdo...Top();"}
 
New Post
1/17/2011 8:43 AM
 
I figured out a bit more of this puzzle and it turns out that there is a Catch-22. 

Here is part of the problem.  ASP Web Controls are executed on the server side (runat=”server”) and render to HTML controls.  However, if the control is disabled then the server does not generate the HTML control and hence you cannot obtain the control in JavaScript.  It might be better to use the Visible attribute to set access to the control as it will always be generated.

2nd.  The web control, ASP:LinkCommand, is not a Form Element like a button.  As DNN hashes the ControlID of the link you cannot use document.getElementByID to obtain a Web Control. 

There has to be a server side way of enabling / disabling the control.

 
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;

 
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