Click here to Skip to main content
15,879,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to all,


I am giving below my java script code Which is using inside aspx file. Here i want to set label text for java script value. Please help me to fix this problem.

XML
<script type="text/javascript">



    var a = $('#<%=Label1.ClientID%>').html();



    var flashvars = {};
    flashvars.userid = "0";
    flashvars.username = "shiva";
    flashvars.roomid = a;




Here how i can set my label1.text = flashvars.roomid


Thanks in advance.
Posted

here is the solution for that.
JavaScript
var temp= $("#Label1").html();

  var flashvars = {};
  flashvars.userid = "0";
  flashvars.username = "shiva";
  flashvars.roomid = temp;
 
Share this answer
 
Comments
Ajith_joseph 14-Jul-12 9:33am    
Thank you once again for your replay,

But still i am unable to get label text in my java script flashvars.roomid. Is there any other method to write code. Thanks.
Abdul Quader Mamun 14-Jul-12 9:39am    
It is working for me fine. Just use like bellow or provide your complete code
Abdul Quader Mamun 14-Jul-12 9:57am    
You need to add reference for a jquery library like this,
<script src="Scripts/jquery-1.7.min.js" type="text/javascript"></script>

it is available on the net.

and put your javascript code in the code block

$(document).ready(function () {
});
Abdul Quader Mamun 14-Jul-12 10:00am    
http://jquery.com/

You need some study about jquery first!
Ajith_joseph 14-Jul-12 10:18am    
Ok , Thank you very much for your answers.
You can use the bellow code:

JavaScript
 $(document).ready(function () {
     var flashvars = {};
     flashvars.userid = "0";
     flashvars.username = "shiva";
     flashvars.roomid = "10"

    $("#Label1").html(flashvars.roomid);
})



Thanks,
Mamun
 
Share this answer
 
Comments
Ajith_joseph 14-Jul-12 8:56am    
Thank you for your response,

If my label text is "abc" Then i want to set my Java script flashvars.roomid = "abc"; How we can write code for this solution? Thanks.
Abdul Quader Mamun 14-Jul-12 9:00am    
flashvars.roomid = "abc"
Abdul Quader Mamun 14-Jul-12 9:00am    
oh
It is working for me fine. Just use like bellow or provide your complete code

JavaScript
$(document).ready(function () {
            var a = $("#Label1").html();

            var flashvars = {};
            flashvars.userid = "0";
            flashvars.username = "shiva";
            flashvars.roomid = a;
});
 
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