<script>
function xxx()
{
if(此处需要调用后台代码查询数据库进行效验)
{
}
......(操作客户端设备的代码) 此处需要调用后台代码更新数据库
}
<script><IMG id="yy" onclick="xxx()" src="../Image/xx.gif">请问该怎么做?或者还有其他方案能达到如此效果(三者的执行顺序不能变,而且只点击一次)?
请高手指点。
function xxx()
{
if(此处需要调用后台代码查询数据库进行效验)
{
}
......(操作客户端设备的代码) 此处需要调用后台代码更新数据库
}
<script><IMG id="yy" onclick="xxx()" src="../Image/xx.gif">请问该怎么做?或者还有其他方案能达到如此效果(三者的执行顺序不能变,而且只点击一次)?
请高手指点。
{
if(<% funtionName() %>)
{
}
......(操作客户端设备的代码) 此处需要调用后台代码更新数据库
}
<script><IMG id="yy" onclick="xxx()" src="../Image/xx.gif">cs code
public bool funtionName()
{
bool success = false;
{
//put you code here
}
return success;
}
这样也是可以的吧
1:可以用隐藏按钮。
2:可以__dopostback一下。
function()
{
var objHttp = new ActiveXObject("Msxml2.XMLHTTP");
strHttp = "getFilesBase.aspx?state=" + fileName;
objHttp.open("get", strHttp, false);
objHttp.send();
}
getFilesBase.aspx,getFilesBase.cs代码:Page_Load函数可调用任意getFilesBase.cs函数:
private void Page_Load(object sender, System.EventArgs e)
{
string strFilePath = @"F:\csv\";
string strRequest = Request.Params[0];
strFilePath += strRequest;
System.IO.Stream iStream = null;
//*
// Buffer to read 10K bytes in chunk:
byte[] buffer = new Byte[10000]; // Length of the file:
int length; // Total bytes to read:
long dataToRead; // Identify the file name.
string filename = System.IO.Path.GetFileName(strFilePath); try
{
// Open the file.
iStream = new System.IO.FileStream(strFilePath, System.IO.FileMode.Open,
System.IO.FileAccess.Read,System.IO.FileShare.Read);
// Total bytes to read:
dataToRead = iStream.Length;
Response.Charset = "Shift-JIS";
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename); // Read the bytes.
while (dataToRead > 0)
{
// Verify that the client is connected.
if (Response.IsClientConnected)
{
// Read the data in buffer.
length = iStream.Read(buffer, 0, 10000);
//UnicodeEncoding temp = new UnicodeEncoding();
//System.Text.UTF8Encoding temp = new UTF8Encoding();
System.Text.Encoding temp = System.Text.Encoding.Default;
string strBuffer = temp.GetString(buffer);
// Write the data to the current output stream.
//Response.OutputStream.Write(buffer, 0, length);
Response.Write(strBuffer); // Flush the data to the HTML output.
Response.Flush(); buffer= new Byte[10000];
dataToRead = dataToRead - length;
}
else
{
//prevent infinite loop if user disconnects
dataToRead = -1;
}
}
实例
http://www.microsoft.com/china/msdn/library/webservices/asp.net/ASPNetSpicedAjax.mspx