Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have an list item in C#
and i want to access to this list in java script
how can i do this
thanks in advance
Posted
Comments
Which list item ?
Please post some code and indicate what exactly you want to do ?
mhd.sbt 14-May-13 3:42am    
i have a
List<ListItem> dataTypes = new List<ListItem>();
in c# and i want to access dataTypeselement by javascript
thank you
Ok. Can you post the html rendered in browser ?
mhd.sbt 14-May-13 4:00am    
why?
i look and see list item not render in my page
I need the rendered html so that I can create a jsFiddle for you which will access these listitems. That will be easy for me.

1 solution

ok I solved this problem by below code:
code behind:
C#
protected  List<listitem> objListItems = new List<listitem>();

And in javaScript
JavaScript
<%
for(int i=0;i<=objListItems .Count;i++)
{
%>
alert('<%=objListItems[i].Text%>')
alert('<%=objListItems[i].Value%>')
<%
}
%>
 
Share this answer
 
v5

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