Passing value from Asp.Net to Extjs
How to pass simple variable created in Asp.Net to Extjs? Lets say a variable in aspx.cs :
public string Name = "ASP.Net";
How to connect it with Extjs, let say a :
Ext.create("Ext.panel.Panel",{
width:100,
width:100,
开发者_高级运维 title: <%=Name %>
});
If I understand your problem correct you have a .aspx page where you include a .js file that contains your javascript code?
You can't use server tags (<%...%>
). There are, however, a few things you can do. The easiest is probably to define a javascript variable in your .aspx page and set the value from your server side variable. Then use that variable in your javascript. You can do that in this way:
*.aspx.cs code:
public string Name = "ASP.Net"
*.aspx code:
<script type="text/javascript>
var title = "<%=Name%>";
</script>
<script type="text/javascript" src="path/to/jsfile.js"></script>
*.js code:
Ext.create("Ext.panel.Panel",{
width:100,
width:100,
title: title
});
Make sure that you define the javascript variable before the .js file is included.
精彩评论