Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
<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>
<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 4-Jan-13 22:41pm
Edited 4-Jan-13 22:54pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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:
document.getElementById('<%=Button2.ClientID%>').click();
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Whenever you add masterpage, control ID's will change, you can view it via view source of your browser.
 
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
  Permalink  

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

  Print Answers RSS
0 Kornfeld Eliyahu Peter 169
1 Zoltán Zörgő 139
2 George Jonsson 135
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 5 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100