Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello ALL,


Please Help me about javascript.

I have added a hyperlink button on master page & call javascript of its onclick event.

ASP.NET
<asp:HyperLink ID="HyperLink2" runat="server" onclick="showHelp('<%=hostCompanyID %>','<%=portaltype1%>');" >Help 


Here hostCompanyID & portaltype1 variable are public & assign a value at backend.

JavaScript
function showHelp(hostid,portal)
{
      alert(hostid);
      alert(portal);
}


but here i don't get value of given variable i got its string as it is...

Please suggest me about that.

thanks in advanced..
Posted
Updated 27-Dec-11 20:42pm
v2
Comments
thatraja 28-Dec-11 3:11am    
What's the value of hostCompanyID & portaltype1?

how can you use backend variable in front end javascript fuction. you try by using hidden fields. you can value to hidden field and pass id of hidden field to script function.

here is more on hidden fields..

googled[^]

hidden field[^]

hiddenfield[^]

http://www.dotnetfunda.com/tutorials/controls/hiddenfield.aspx[^]
 
Share this answer
 
Comments
madhuri@mumbai 28-Dec-11 3:04am    
yes i have done it ,but i dont get value in javascript
Remove the

ASP.NET
runat="server"


and it will work.

but if you want it to be server side control you have to set its OnClick in page OnLoad part :
C#
HyperLink2.Attributes.Add("OnClick", string.Format("showHelp('{0}','{1}');", hostCompanyID, portaltype1));


Hope it helps.
 
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