点击一个HTML的BUTTON 调用服务端事件,我用的是AjaxPro.2.dll,比如 <input id="Button2" type="button" value="button" onclick="tj();" /><script language="javascript">
function tj()
{Telesa.tijiao();
}
</script>后台:已注册好,引用好 [AjaxPro.AjaxMethod]
public void tijiao(string str)
{
Response.Write("11");//这句效果不能实现
Label1.Text="22";//也不能
}
function tj()
{Telesa.tijiao();
}
</script>后台:已注册好,引用好 [AjaxPro.AjaxMethod]
public void tijiao(string str)
{
Response.Write("11");//这句效果不能实现
Label1.Text="22";//也不能
}
解决方案 »
- 截取字符串问题
- 这道题你会么??
- JScript中table、tableCell、tableRow的运用
- 重命名一个文件后如何在整个方案中自动套用这个改变?
- Infopath用户角色设置的问题,如何根据表单用户名来实现读写控制。
- 请问 datagrid 如何 在列头中 标题文本 和 图片 一起显示 ,必须可以点击列头 实现 排序,就是可以 触发 SortCommand 事件 !!!! 急
- 在b/s下操作Visio的问题(C# and .net )?
- 给个asp.net连接ORACLE的示例
- Datagrid里面每一行里面的一个控件怎么都让他添加到属性啊??
- ASP.NET上传附件的问题,为什么我修改了webconfig中的上传文件大小限制还是不能上传成功?
- js 里的模态窗口
- 怎样用sql语句直接生成XML文件
放一个button按钮ID为btnLogin,按钮下写好事件,将按钮设为隐藏,前台js代码里写函数:
function tj()
{
document.getElementById("btnLogin").click();
}
</script>
{
public static DataSet GetCountryList()
{
DataSet ds = new DataSet();
return ds;
} [Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
public DataSet GetProvinceList(string strCountry)
{
}
function ProResult()
{
var city=document.getElementById("ddl_country");
AjaxMethod.GetProvinceList(city.value,get_pro_Result);
}
或通过web servicea输出值
public class RegistValidate : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
string username = HttpUtility.UrlDecode(context.Request.QueryString["username"].ToString());
DataSet ds ;
if (ds.Tables[0].Rows.Count > 0)
{
context.Response.Write("该用户名已经有人使用!" + username);
}
else
{
context.Response.Write("可以使用!" + username);
}
ds.Dispose();
System.Threading.Thread.Sleep(1000);
}
public bool IsReusable {
get {
return false;
}
}}
[AjaxPro.AjaxMethod]
public string tijiao(string str)
{
return "22"
}在后台的js函数用有个你定义的成功的处理函数有个参数result,然后把这个result赋给<span>
要操纵页面,使用JavaScript来做,这才是使用ajax中的j即javascript啊
Response.Write("注册功能");
[AjaxPro.AjaxMethod]
public void tijiao(string str)
{
Response.Write("11");//这句效果不能实现
Label1.Text="22";//也不能
}这样是不行的,你可以返回值的时候再用js操作
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CallBack_Default.aspx.cs" Inherits="CallBack_Default" %><!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 runat="server">
<title>使用.net回调(CallBack)技术实现局部刷新</title>
<script language="javascript">
function FillData()
{
var city = document.getElementById("TextBox1").value;
<% =ClientScript.GetCallbackEventReference(this,"city","FillDll",null) %>;
}
function FillDll(strCity)
{
document.getElementById("DropDownList1").options.length = 0;
var indexofcity;
var city;
//分割传递来的字符串
while(strCity.length>0)
{
//判断是否是最后一个字符串
indexofcity = strCity.indexOf(",");
if (indexofcity > 0)
{
city = strCity.substring(0,indexofcity);
strCity = strCity.substring(indexofcity+1);
//填充DropDownList1
document.getElementById("DropDownList1").add(new Option(city,city));
}
else
{
document.getElementById("DropDownList1").add(new Option(strCity,strCity));
break;
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<strong>使用.net回调(CallBack)技术实现局部刷新</strong><br />
城市名称:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input id="Button1" type="button" value="查 询" onclick="FillData()" /><br />
城镇:<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList></div>
</form>
</body>
</html>public partial class CallBack_Default : System.Web.UI.Page,ICallbackEventHandler
{
private string _data; protected void Page_Load(object sender, EventArgs e)
{ } public string GetCallbackResult()
{
return _data;
} public void RaiseCallbackEvent(string eventArgument)
{
switch (eventArgument)
{
case "武汉":
_data = "武昌,汉口,洪山";
break;
case "钟祥":
_data = "郢中,胡集,双河";
break;
default:
break;
}
}}
有没有其他好的AJAX框架好实现这个功能?
public void tijiao(string str)
{
Response.Write("11");//这句效果不能实现
Label1.Text="22";//也不能
}这个方法不能分开写么?
Response.Write() jquery 很容易实现
Label1.Text="" 这个用javascript实现不行么