這包括了JS調用c#方法
JS代碼
<script language=
var JSVar =
function getcsharpstring() {
//去調用c#的函數
var mys =
//沒有參數的可以這樣寫var mys =
alert(mys)
}
function getcsharpvar() {
var mys =
alert(mys)
}
//此函數用於C#調用
function CSharpCall() {
alert(
//設置一個cookie
okie =
}
</script>
c#後台代碼
public partial class _Default : System
{
public string CSharpVar =
protected void Page_Load(object sender
{
}
//被JS調用
public string CSharpString(string _string )
{
return
}
protected void Button
{
string jsString =
Page
}
protected void Button
{
//通過讀取cookie 來得到JS的變量
HttpCookie cookie = Request
if (cookie != null)
{
string jsVar = cookie
}
//可以用同樣的方法讓JS訪問c#代碼
/*
c#(加)
using System
HttpCookie UserCookie = new HttpCookie(
Response
(注銷)
Request
//將Cookies[
HttpCookie customerCookie = new HttpCookie(
Response
JS
function getCookie(objName)
{//獲取指定名稱的cookie的值
var arrStr = okie
for(var i =
{
var temp = arrStr[i]
if(temp[
}
}
function delCookie(name)
{//為了刪除指定名稱的cookie
var date = new Date();
date
okie = name +
}
*/
}
}
以上兩個
From:http://tw.wingwit.com/Article/program/net/201311/13040.html