由用户触发
function oncallbacknobtn()
{
callserver(document.getelementbyid('txtusername').value,"");
}
public partial class webpage_callbackbtn : system.web.ui.page, icallbackeventhandler
{
protected string struserinfo; //callback最终得到的信息
protected void page_load(object sender, eventargs e)
{
}
#region icallbackeventhandler 成员
public string getcallbackresult()
{
return struserinfo;
}
public void raisecallbackevent(string eventargument) //服务端的处理函数
{
if (eventargument == "") return;
system.data.sqlclient.sqlconnection conn = new system.data.sqlclient.sqlconnection();
conn.connectionstring = system.web.configuration.webconfigurationmanager.connectionstrings["nowthwindconnectionstring"].connectionstring;
sqlcommand cmd = new sqlcommand();
cmd.commandtype = commandtype.text;
cmd.parameters.add("@firstname", sqldbtype.nvarchar, 10)
.value = eventargument;
cmd.commandtext = "select employeeid, lastname from employees where firstname=@firstname";
cmd.connection = conn;
sqldatareader reader;
connectionstate previousconnectionstate = conn.state;
try
{
if (conn.state == connectionstate.closed)
{
conn.open();
}
reader = cmd.executereader();
using (reader)
{
while (reader.read())
{
// process sprocresults datareader here.
struserinfo += reader[0];
}
}
struserinfo += "###";
}
finally
{
if (previousconnectionstate == connectionstate.closed)
{
conn.close();
}
}
}
#endregion
}
protected void page_load(object sender, eventargs e)
{
string cbreference = page.clientscript.getcallbackeventreference(this,"arg", "receiveserverdata", null);
//page.clientscript.getcallbackeventreference(this,"arg", "receiveserverdata", null);
string callbackscript;
callbackscript = "function callserver(arg,context){" + cbreference + "};";
//string callbackscript = "function callserver(arg,context){webform_docallback('__page',arg,receiveserverdata,null,null,false)};";
page.clientscript.registerclientscriptblock(this.gettype(), "callserver123", callbackscript, true);
}
我的博物馆故事 官方安卓版v1.61.2
我的博物馆故事是一款以消除为主题的经营养成类手游,在这里玩家
专业模拟飞行10 手机版v12.2.4
专业模拟飞行10安卓版是一款飞行休闲手游,顶尖的物理飞行引擎
动物起义战斗模拟器二琳同款 最新版v4.1.1
动物起义战斗模拟器是一个非常有趣的模拟类游戏,玩家可以召唤各
迷你世界七周年 安卓手机版v1.43.0
迷你世界7周年是一款由《迷你世界》官方推出的庆祝特别版本,在
劫后公司无限资源版 v1.0.5.1
劫后公司内置菜单版是游戏的破解版本,在该版本中为玩家提供了内