Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
hi friends!!
im working in web application... always trouble master page with server side control.... i need disable some buttons when im clicking dropdownlist... but its not work...
any one pls help me out this...
here is one of the code:

XML
<asp:DropDownList ID="DropDownList1" runat="server" Width="75px">
       <asp:ListItem Value="*">Select</asp:ListItem>
       <asp:ListItem Value="Route">Route</asp:ListItem>
       <asp:ListItem Value="Bus No">Bus No</asp:ListItem>
       <asp:ListItem Value="Shift">Shift</asp:ListItem>
       <asp:ListItem Value="Conductor">Conductor</asp:ListItem>
       <asp:ListItem Value="Driver">Driver</asp:ListItem>
   </asp:DropDownList>




PHP
$(document).ready(function(){
 var $information=$("#lbl_Info");
  $("#DropDownList1").change(function() {
  alert('hi im Work');
            if ($('#selNoOfStudentRecords').val() == "*")
            {
                $("#Button1").attr("disabled", true);
                $("#Button1").removeClass("ButtonStyle");
                $("#Button1").addClass("ButtonDisabled");
                $("#Button2").attr("disabled", true);
                $("#Button2").removeClass("ButtonStyle");
                $("#Button2").addClass("ButtonDisabled");
                $information.html("Please Select Your Options");

            } else {
                $("#Button1").attr("disabled", false);
                $("#Button1").removeClass("ButtonDisabled");
                $("#Button1").addClass("ButtonStyle");
                $("#Button2").attr("disabled", false);
                $("#Button2").removeClass("ButtonDisabled");
                $("#Button2").addClass("ButtonStyle");
                $information.html("Your Option Selected");
            }
        }).change();
 });


regards
sarva
Posted
Comments
Sandeep Mewara 28-Aug-12 2:14am    
Did you debug and see the execution? Any error? Workflow?
Sarrrva 28-Aug-12 2:26am    
No error But that dropdownlist change fucntion not fire.... any idea pls?

1 solution

finally i solved this Problem:

XML
<script type="text/javascript">
 $(document).ready(function(){
 var btn1 = $("#<%=Button1.ClientID%>");
 var btn2 = $("#<%=Button2.ClientID%>");
 var Sel=$("#<%=DropDownList1.ClientID %>");
 var $information=$("#lbl_Info");
  $(Sel).change(function() {
            if ($(Sel).val() == "*")
            {
                $(btn1).attr("disabled", true);
                $(btn1).removeClass("ButtonStyle");
                $(btn1).addClass("ButtonDisabled");
                $(btn2).attr("disabled", true);
                $(btn2).removeClass("ButtonStyle");
                $(btn2).addClass("ButtonDisabled");
                $information.html("Please Select Your Options");

            } else {
                $(btn1).attr("disabled", false);
                $(btn1).removeClass("ButtonDisabled");
                $(btn1).addClass("ButtonStyle");
                $(btn2).attr("disabled", false);
                $(btn2).removeClass("ButtonDisabled");
                $(btn2).addClass("ButtonStyle");
                $information.html("Your Option");
                            }
        }).change();
 });
 </script>



XML
<asp:DropDownList ID="DropDownList1" runat="server" Width="75px">
        <asp:ListItem Value="*">Select</asp:ListItem>
        <asp:ListItem Value="Route">Route</asp:ListItem>
        <asp:ListItem Value="Bus No">Bus No</asp:ListItem>
        <asp:ListItem Value="Shift">Shift</asp:ListItem>
        <asp:ListItem Value="Conductor">Conductor</asp:ListItem>
        <asp:ListItem Value="Driver">Driver</asp:ListItem>
    </asp:DropDownList>



and One More thing:

we need specify Master Page with Button selector
like this

var btn1 = $("#<%=Button1.ClientID%>");


and textbox selectors
like this format:

$("input[id$='FCDate']").datepicker();



regards
sarva
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900