2
我有一個在buttonclick填充一個列表框,然後當用戶選擇或更改就可以下載與其相關的文件列表框的索引。asp.net listbox_index改回發射擊上的每個按鈕
我的問題是,當他們去按一個按鈕再次搜索它下載文件的新紀錄,但低於再次發射的代碼。如何阻止它在其他按鈕上調用回發?
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string splitval = ListBox1.SelectedValue.ToString();
string[] newvar = splitval.Split(',');
GlobalVariables.attachcrq = newvar[0];
GlobalVariables.num = UInt32.Parse(newvar[1]);
string filename = ListBox1.SelectedItem.ToString();
GlobalVariables.ARSServer.GetEntryBLOB("CHG:WorkLog", GlobalVariables.attachcrq, GlobalVariables.num, Server.MapPath("~/TEMP/") + filename);
FileInfo file = new FileInfo(Server.MapPath("~/TEMP/" + filename));
Response.Clear();
Response.AppendHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AppendHeader("Content-Length", file.Length.ToString());
Response.ContentType = ReturnExtension(file.Extension.ToLower());
Response.TransmitFile(file.FullName);
Response.Flush();
Response.End();
}
這將如何代碼執行過呢?列表框是一個按鈕,點擊後填充,在這一點併爲未來的回傳!Page.IsPostback永遠不會爲真 – CRice 2013-05-02 04:54:46
它現在沒有運行的代碼都當我改變了指數,它只是閃爍 – stefan 2013-05-02 04:55:41
嘗試設置的AutoPostBack =「真正的」到你的列表框 – CRice 2013-05-02 04:56:22