Click here to Skip to main content
15,998,008 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to define dynamic variable in javascript?


i have a usercontrol with jquery ,its variable static names makes problems when i am using two instance of that user control...
XML
<script>
function getTooltips() {
    $(document).ready(function () {

        var x = $.jQax(
    {
        LoaderContainerId:  "#" + "<%=divMyLoadingDiv2.ClientID %>";,
        LoaderText: "."
    });


        var datePicker = $('#' + '<%= JQDatePicker1.ClientID %>').val();
        var data1 = "{ myDate : '" + datePicker + "' }";

        x.Post("<%=getServicePath() %>", data1,
                    function (data1, eventArgs) {
                        var result1 = data1.d;
                        $('#' + '<%= lblTitle.ClientID %>').html(result1);

                        if (result1.toString().charAt(0) == "1") {
                            $('#' + '<%= JQDatePicker1.ClientID %>').addClass("datePicker9");


                        }
                        else {

                            $('#' + '<%= JQDatePicker1.ClientID %>').removeClass("datePicker9");


                        }
                        var res = result1.replace(result1.charAt(0), "");
                        $('#' + '<%= lblTitle.ClientID %>').html(res);
                        $('#' + '<%= hdn.ClientID %>').val(res);

                    }, true, "", function (data1, eventArgs) { alert('error') }
                );
    });


    function pageLoad(sender, args) {
        if (args.get_isPartialLoad()) {
            getTooltips();
        }
    }


}
</script>


<table dir="rtl">
    <tr>
        <td>


         <cc1:JQDatePicker ID="JQDatePicker1"    runat="server"
                IsRTL="True" DateFormat="YMD"   önchange="getTooltips();"
                Height="23px" AnimationType="Slide" IEDateFormat="YMD" Regional="fa"
                ChangeMonth="True" ChangeYear="True" Width="75px"></cc1:JQDatePicker>
     <asp:Label ID="lblTitle" runat="server" Font-Size="8pt"></asp:Label>
     <asp:HiddenField ID ="hdn" runat ="server" />
   <div id="divMyLoadingDiv2"  runat="server">

            </div>
        </td>
    </tr>
</table>
Posted
Updated 11-Jan-12 21:01pm
v2
Comments
Sergey Alexandrovich Kryukov 12-Jan-12 2:56am    
Not clear.
--SA

There is not such thing as "static names". In JavaScript, everything is dynamic. :-)

You did not explain what you want to achieve and why, sorry. Right now, you have no chance to get more help. If you change your mind, use "Improve question" above, but this time think well at the question.

—SA
 
Share this answer
 
var msg_<% =control.ClientID %>
 
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