Click here to Skip to main content
15,890,043 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I want to call a javascript function from my ASP.NET (C#) code,

tag_label.Attributes["onmouseover"] = "tooltip.show('Hard coded value:');
after this 'Hard coded value' I want to add a variable (string) to the method.How should i pass these value??
for eg:
string var=India;(this string value changes programmaticly like us,uk,jappan etc...)
tag_label.Attributes["onmouseover"] = "tooltip.show('Hard coded value:');";
the tooltip display should be "Welcome to India" on mouseover how can i achive this??
help me please...
Posted
Updated 13-Aug-12 23:55pm
v3

1 solution

Try this..working fine.

C#
string passstr = string.Empty;
passstr = "I Love My India";
tag_label.Attributes.Add("onmouseover", "tooltip.show('"+ passstr +"')");


What I tried, because tooltip is unassigned for me.

C#
string passstr = string.Empty;
passstr = "I Love My India";
tag_label.Attributes.Add("onmouseover", "alert('"+ passstr +"')");



Thanks
Ashish
 
Share this answer
 
Comments
Sachin Gargava 14-Aug-12 5:41am    
good 5+

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