62,243
社区成员




using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Website
{
public partial class TESTTTTT : System.Web.UI.Page
{
public string name = "我是后台变量";
protected void Page_Load(object sender, EventArgs e)
{
this.DataBind();
}
//不能为private
protected string StrTest()
{
return "这是前台通过<%# %>调用后台方法";
}
public void StrTest2()
{
Response.Write("这是前台通过<%= %>调用后台方法");
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TESTTTTT.aspx.cs" Inherits="Website.TESTTTTT" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<b>服务器控件</b><br />
<br />
服务器端文本框绑定后台方法:<asp:TextBox ID="TextBox1" runat="server" Text="<%#StrTest()%>"></asp:TextBox><%=StrTest()%><br />
<br />
<br />
......................变量:<asp:TextBox ID="TextBox2" runat="server" Text="<%#name%>"></asp:TextBox><br />
<br />
<br />
服务器端文本框绑定后台方法:<asp:Label ID="Label1" runat="server" Text="Label"><%=StrTest()%></asp:Label><br />
<br />
<br />
服务器端文本框绑定后台方法:<asp:Label ID="Label2" runat="server" Text="<%#StrTest() %>"></asp:Label><br />
<br />
<br />
<b>客户端控件</b><br />
<br />
客户端文本框绑定后台方法:<input id="Text1" type="text" value="<%#StrTest()%>" /><%=name %><br />
<br />
<br />
客户端标签:
<div><%=StrTest() %></div>
<div>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="<%#name %>" OnClientClick="return confirm('确认要删除此行信息吗?')" />
<br />
<br />
<asp:Button ID="Button3" runat="server" Text="<%#name %>" OnClientClick="<%# "return confirm('" + Eval("name") + "')" %>" />
</div>
</div>
</form>
</body>
</html>
function abc()
{
if(confirm("确实要删除吗?")){
return true;
}else {
return false;
}
}