0

Not able to assign validation group on the click of button.

<asp:TabPanel ID="tabpnlTwo" runat="server" Visible="false" Width="100%" OnClientClick="radiobuttonvalidationForTabOne">
       <ContentTemplate>
  </ContentTemplate>

<asp:TabPanel ID="tabpnlTwo" runat="server" Visible="false" Width="100%" OnClientClick="radiobuttonvalidationForTabTwo">
       <ContentTemplate>
  </ContentTemplate>

here on the tabpnanel calling script function onClientClick where assigning validation group to button

  <script>
    function radiobuttonvalidationForTabOne() {
        var btnAddOrderId = document.getElementById("btnAddToOrder");
        btnAddOrderId.ValidationGroup = "tabpnlOneGroup";

        alert(btnAddOrderId.ValidationGroup);
    }
    </script>

    <script>
function radiobuttonvalidationForTabTwo() {
    var btnAddOrderId = document.getElementById("btnAddToOrder");
    btnAddOrderId.ValidationGroup = "tabpnlTwoGroup";
    alert(btnAddOrderId.ValidationGroup);
}
</script>


 <asp:Button ID="btnAddToOrder" CssClass="customButton" runat="server" Text="Add To Order" ValidationGroup="tabpnlOneGroup"
           onclick="btnAddToOrder_Click" />

2 Answers 2

2

use

<anycontrol runat="server" id="anyone" ClientIDMode="Static"/>

Using ClientIDMode Static with the control's attribute will solve your problem.

No Using Jquery or javascript:

$('#anyone').anyfunctioncallback()
{
}
Sign up to request clarification or add additional context in comments.

Comments

1

This is because the id of you button changes on run time. You need to use

 var btnAddOrderId = document.getElementById('<%=btnAddToOrder.ClientID%>');

instead of

 var btnAddOrderId = document.getElementById("btnAddToOrder");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.