Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
JavaScript
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js" />
    <script type="text/javascript" language="javascript">
        function buttonclick() {
            document.getElementById('Button2').click();
        }
    </script>

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

        $(document).ready(function() {
            $("#Button2").click(function() {
                autoComp();
            });
            $(function autoComp() {
                //  alert('hello');
                var textb = document.getElementById('TextBox1').value;

                if ((textb != null) && (textb != "")) {
                    if (parseInt(textb) == 0) {
                        $("#image1").fadeTo("fast", 0.15);
                        $("#image2").fadeTo("fast", 0.15);
                        $("#image3").fadeTo("fast", 0.15);
                        $("#image4").fadeTo("fast", 0.15);
                        $("#image4").fadeTo("fast", 0);
                    }

                    if (parseInt(textb) == 25) {

                        $("#image1").fadeTo("fast", 0.25);
                        $("#image2").fadeTo("fast", 0.25);
                        $("#image3").fadeTo("fast", 0.25);
                        $("#image4").fadeTo("fast", 0.25);
                    }
                    if (parseInt(textb) == 50) {
                        $("#image1").fadeTo("fast", 0.5);
                        $("#image2").fadeTo("fast", 0.5);
                        $("#image3").fadeTo("fast", 0.5);
                        $("#image4").fadeTo("fast", 0.5);
                    }
                    if (parseInt(textb) == 75) {
                        $("#image1").fadeTo("fast", 0.75);
                        $("#image2").fadeTo("fast", 0.75);
                        $("#image3").fadeTo("fast", 0.75);
                        $("#image4").fadeTo("fast", 0.75);

                    }
                    if (parseInt(textb) == 100) {
                        $("#image1").fadeTo("fast", 1);
                        $("#image2").fadeTo("fast", 1);
                        $("#image3").fadeTo("fast", 1);
                        $("#image4").fadeTo("fast", 1);
                    }
                }
            });
        });    
    </script>

XML
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
<div id="div1" style="background-color: #000000"  runat="server">
<asp:Image ID="image1" runat="server" AlternateText="Ledbulb" ImageUrl="Images/Transparent_Bulb.png" />
    ;<asp:Image ID="image2" runat="server" AlternateText="Ledbulb" ImageUrl="Images/Transparent_Bulb.png" />

<asp:Image ID="image3" runat="server" AlternateText="Ledbulb" ImageUrl="Images/Transparent_Bulb.png" />

<asp:Image ID="image4" runat="server" AlternateText="Ledbulb" ImageUrl="Images/Transparent_Bulb.png" />
    <br />
    <asp:Image ID="Image5" runat="server" Width="100%" ImageUrl="~/Images/Road.PNG" />
    <br />

    <asp:Label ID="Label1" runat="server" Text="PoleID : P1" ForeColor="White" Font-Bold="True"></asp:Label>

    <br />
    <asp:Label ID="Label5" runat="server" Font-Bold="True" ForeColor="White"
        Text="DutyCapaciy :"></asp:Label>
<asp:Label ID="lblDC1" runat="server" ForeColor="White" >NULL</asp:Label>

</div><br>
<asp:Button ID="Button2" runat="server" Text="Display"/>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="Server" AssociatedUpdatePanelID="UpdatePanel1" DisplayAfter="1" >
<ProgressTemplate>Update in Progress……..  </ProgressTemplate>
</asp:UpdateProgress>

The above code it is working in individual page fine but whenever i add the master page it is not working help me from this
Posted
Updated 4-Jan-13 21:54pm
v2

working in individual page fine but whenever i add the master page it is not working
This is because with Masterpage, the actual ID's of server control are little different.

To have a quick and easy solution, do a 'View Source' of the webpage and get the ID of the control you need and use that ID in JavaScript.

Another way is to use delimiters like:
JavaScript
document.getElementById('<%=Button2.ClientID%>').click();
 
Share this answer
 
Whenever you add masterpage, control ID's will change, you can view it via view source of your browser.

JavaScript
var textb = document.getElementById('TextBox1').value;


Above won't work when there is masterpage added. Do as sandeep mewara suggested, you can also do the following

var textb = document.getElementById('contentplaceholeID').value


paste the id of your control after viewing the source of your page.


Thanks
 
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