asp.net后台向前台注册js函数和数组
1. 注册js函数
String scriptString = "<script language=JavaScript>function doClick(){";
scriptString += "for(var index=0;index<myArray.length;index++)";
scriptString += "alert(myArray[index]);}<";
scriptString += "/" + "script>";
ClientScript.RegisterStartupScript(typeof(WebForm2), "arrayScript", scriptString);
2. 注册数组
ClientScript.RegisterArrayDeclaration("myArray", "\"x\",\"y\",\"z\"");
相关文档:
获取网站根目录的方法有几种如:
Server.MapPath(Request.ServerVariables["PATH_INFO"])
Server.MapPath("/")
Server.MapPath("")
Server.MapPath(".")
Server.MapPath("../")
Server.MapPath("..")
&nb ......
1:在.aspx页面,<% %>标签相当于在.cs页面的代码,也就是说你在.cs文件里面怎样写,就可以在.aspx文件里面的<% %>标签里面怎样写。
2:在.aspx页面,<%= %>标签可以调用你的后台的变量或者方法等,不过被调用的方法必须是public的。
如果你的Default.cs文件里面有:
public string str = "调用后台方 ......
在C#中
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using System.Collections.Generic;
using System.Collections;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.Ba ......
-----------------------------.cs类文件中
当前项目的物理路径嘛:
strPath = this.Server.MapPath(Request.PhysicalApplicationPath);
你要说明什么“类文件”。任何PAGE、CONTROL代码也是在类 ......