请教如何前台调用后台代码(简单)
前台代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm7.aspx.cs" Inherits="Test.WebForm7" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1"> <title></title> <link href="Css/default.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" type="text/css" href="js/themes/default/easyui.css" /> <link rel="stylesheet" type="text/css" href="js/themes/icon.css" /> <script type="text/javascript" src="js/jquery-1.4.1.min.js"></script> <script type="text/javascript" src="js/jquery.easyui.js"></script> <script type="text/javascript" src='js/outlook2.js'> </script> <script type="text/javascript"> var _menus = { "menus": [ "<%=fun()%>"// {'menuid': '1', 'icon': 'icon-sys', 'menuname': '门诊处方',// "menus": [{ "menuname": "菜单管理", "icon": "icon-nav", "url": "http://hxling.cnblogs.com" },// { "menuname": "添加用户", "icon": "icon-add", "url": "demo.html" },// { "menuname": "用户管理", "icon": "icon-users", "url": "demo2.html" },// { "menuname": "角色管理", "icon": "icon-role", "url": "demo2.html" },// { "menuname": "权限设置", "icon": "icon-set", "url": "demo.html" },// { "menuname": "系统日志", "icon": "icon-log", "url": "demo.html" }// ]// }, { "menuid": "28", "icon": "icon-sys", "menuname": "财务管理",// "menus": [{ "menuname": "收支分类", "icon": "icon-nav", "url": "demo2.html" },// { "menuname": "报表统计", "icon": "icon-nav", "url": "demo2.html" },// { "menuname": "添加支出", "icon": "icon-nav", "url": "demo2.html" }// ]// } ] };
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace Test{ public partial class WebForm7 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } public String get() { return "门诊处方"; } public void fun() { String x = "{ 'menuid': '1', 'icon': 'icon-sys', 'menuname': '门诊处方'," + "'menus': [{ 'menuname': '菜单管理', 'icon': 'icon-nav', 'url': 'http://hxling.cnblogs.com' }," + "{ 'menuname': '添加用户', 'icon': 'icon-add', 'url': 'demo.html' }," + "{ 'menuname': '用户管理', 'icon': 'icon-users', 'url': 'demo2.html' }," + "{ 'menuname': '角色管理', 'icon': 'icon-role', 'url': 'demo2.html' }," + "{ 'menuname': '权限设置', 'icon': 'icon-set', 'url': 'demo.html' }," + "{ 'menuname': '系统日志', 'icon': 'icon-log', 'url': 'demo.html' }]}," + "{ 'menuid': '28', 'icon': 'icon-sys', 'menuname': '财务管理'," + "'menus': [{ 'menuname': '收支分类', 'icon': 'icon-nav', 'url': 'demo2.html' }," + "{ 'menuname': '报表统计', 'icon': 'icon-nav', 'url': 'demo2.html' }," + "{ 'menuname': '添加支出', 'icon': 'icon-nav', 'url': 'demo2.html' }]}"; Response.Write(x); } //public String fun() //{ // return "{ 'menuid': '1', 'icon': 'icon-sys', 'menuname': '门诊处方'," // + "'menus': [{ 'menuname': '菜单管理', 'icon': 'icon-nav', 'url': 'http://hxling.cnblogs.com' }," // + "{ 'menuname': '添加用户', 'icon': 'icon-add', 'url': 'demo.html' }," // + "{ 'menuname': '用户管理', 'icon': 'icon-users', 'url': 'demo2.html' }," // + "{ 'menuname': '角色管理', 'icon': 'icon-role', 'url': 'demo2.html' }," // + "{ 'menuname': '权限设置', 'icon': 'icon-set', 'url': 'demo.html' }," // + "{ 'menuname': '系统日志', 'icon': 'icon-log', 'url': 'demo.html' }]}," // + "{ 'menuid': '28', 'icon': 'icon-sys', 'menuname': '财务管理'," // + "'menus': [{ 'menuname': '收支分类', 'icon': 'icon-nav', 'url': 'demo2.html' }," // + "{ 'menuname': '报表统计', 'icon': 'icon-nav', 'url': 'demo2.html' }," // + "{ 'menuname': '添加支出', 'icon': 'icon-nav', 'url': 'demo2.html' }]}"; //} }}