Interactive change on the page.

Last post 07-24-2008 11:57 PM by Pawan_Mishra. 6 replies.

Sort Posts:

  • Interactive change on the page.

    07-23-2008, 6:24 PM

    Hi all,

                I have a problem, I have a drop down list and a check box list. I only want to enable my Check box list when the dropdownlist is select Yes option and when the user select no or any other option on the drop down list i dont want to disabled the list, it is very simple if you are doing this with a postback but is there a way to do it using ajax or javascript. Any help will be much appreciated.

    Thanks.

    Kabir

  • Re: Interactive change on the page.

    07-23-2008, 10:03 PM
    • Loading...
    • soeethiha
    • Joined on 12-05-2007, 8:44 AM
    • Singapore
    • Posts 22

     You can use Updatepanel Control. This AJAX Extensions from Microsoft. It can be use from VS.2005 and above. for 2003 I am not too sure.

    Soee Thiha
  • Re: Interactive change on the page.

    07-24-2008, 1:17 AM
    • Loading...
    • Pawan_Mishra
    • Joined on 03-13-2008, 7:37 AM
    • Bangalore
    • Posts 221

    HI

    You can do it using javascript . The following code can be used ( its jst a sample or better to say an approach) :-

    function pageLoad()

    {

    $addHandler($get('<id of your dropdown control>' ), '<event-name>', onSelectionChanged);

    }

     

    function pageunload()

    {

    $removeHandler($get('<id of your dropdown control>' ), '<event-name>', onSelectionChanged);

    }

    function onSelectionChanged(evt)

    {

    var obj = $get('<id of your dropdown control>');

    if(obj.value === 'Yes')

    {

    $get('<id of your check box list control>').visible = true/false(it is as per your requirement);

    }

    }

    This code snippet shows the approach to solve your problem using javascript .

    Try this approach .. hope it works :-)

    Regards

    Pawan Mishra

     

     

    Regards

    Pawan Mishra


    "Mark the post as answered if it solves your query"
  • Re: Interactive change on the page.

    07-24-2008, 1:12 PM

    Thanks i am trying this right now what do I put in the eventname portion of the handler is it the java event name or what can you explain a bit...

    Thanks

    Kabir

  • Re: Interactive change on the page.

    07-24-2008, 1:37 PM

    I have wrote the following code, but nothing is happening when i click on the drop down list, when i try to debug it the function onSelectionChanged does not get fire at anytime when i am making changes to the dropdown list. Please advice ...

       function pageLoad()
        {
            $addHandler($get('<%=drTstAccUsedDropDownList.ClientId %>' ), 'onchange', onSelectionChanged);
        }    

        function pageunload()
        {
            $removeHandler($get('<%=drTstAccUsedDropDownList.ClientId %>' ), 'onchange', onSelectionChanged);
        }

        function onSelectionChanged(evt)
        {
            var obj = $get('<%=drTstAccUsedDropDownList.ClientId %>');
            if(obj.value == 'Yes')
            {
                $get('<%=drDisAudioTpCheckBox.ClientId %>').disabled = true;
            }
        }

      

    Thanks

    Kabir

     

  • Re: Interactive change on the page.

    07-24-2008, 3:38 PM
    Answer

     I have solved my own problem but i used your idea instead of adding the handler from javascript i added attribute to the dropdown "onchange" and let it fire the onselectionchanged event with no parameters and it worked, here is the code for people who would read this

    in the page load

    drTstAccUsedDropDownList.Attributes.Add("onchange", "TestAcmonSelectionChanged(); return false;")

    in the srcipt

    function TestAcmonSelectionChanged()
        {
            var obj = $get('<%=drTstAccUsedDropDownList.ClientId %>');
            if(obj.value == 'Yes')
            {
                $get('<%=drDisAudioTpCheckBox.ClientId %>').disabled = false;
            }
            else
            {
                $get('<%=drDisAudioTpCheckBox.ClientId %>').disabled = true;
            }
        }
     Thanks all and this topic is now closed.
    Kabir
    
     
  • Re: Interactive change on the page.

    07-24-2008, 11:57 PM
    • Loading...
    • Pawan_Mishra
    • Joined on 03-13-2008, 7:37 AM
    • Bangalore
    • Posts 221

    Hi

    In the $addHandler() method second parameter is event . Now when you are assigning event handler's for various events  using $addHandler() event name should not start with on ie onSelectionChange becomes SelectionChange , onClick becomes Click . In fact , I read in one post that event name should start with lower case letter ie click , selectionchanger etc. And one more thing in $get() you have to pass id , for that you can view source of your web page and therer you can get the id of your respective element .

    Regards

    Pawan Mishra

     

    Regards

    Pawan Mishra


    "Mark the post as answered if it solves your query"
Page 1 of 1 (7 items)
Microsoft Communities
Page view counter