這時上傳一個沒有內容的 .txt 文件會使得 HasFile 的判斷為 false ,檔案則無法上傳成功
所以將
1 |
改為
1 |
一併執行判別最安全 if (FileUpload1.HasFile || (FileUpload1.FileName.Length > 0))
1 | if (FileUploadField.HasFile) |
1 | if (FileUploadField.FileName.Length > 0) |
<object id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0 VIEWASTEXT>object> <input type=button value=列印 onclick=document.all.WebBrowser.ExecWB(6,1) id="Button2"name="Button2"> <input type=button value=直接列印 onclick=document.all.WebBrowser.ExecWB(6,6) id="Button3"name="Button3"> <input type=button value=頁面設置 onclick=document.all.WebBrowser.ExecWB(8,1) id="Button4"name="Button4"> <input type=button value=列印預覽 onclick=document.all.WebBrowser.ExecWB(7,1) id="Button5"name="Button5"> |
<head runat="server"> <title>列印頁面測試title> <script type="text/javascript" src="print.js">script> head> ----------------------- <div id="print_parts"> <asp:Button ID="Button2" runat="server" Text="Button" /> <asp:GridView ID="GridView2" runat="server"> asp:GridView> ...... 所有你想放的內容,放於此區塊 div> -------------------------- <asp:Button ID="Button1" runat="server" Text="Button"Height="61px" onclientclick="printScreen(print_parts)"Width="248px" onclick="Button1_Click" /> |
function printScreen(printlist) { var value = printlist.innerHTML; var printPage = window.open("", "Printing...", ""); printPage.document.open(); printPage.document.write(""); printPage.document.write(" ");
printPage.document.write(value);
printPage.document.write(" ");printPage.document.close(""); } |
protected void Button1_Click(object sender, EventArgs e) { Page.ClientScript.RegisterClientScriptInclude("myPrint","print.js"); // public void RegisterClientScriptInclude(string key, string url) // http://msdn.microsoft.com/en-us/library/2552td66.aspx} |
// File: TestCode.cs using UtilityMethods; class TestCode { static void Main(string[] args) { System.Console.WriteLine("Calling methods from MathLibrary.DLL:"); if (args.Length != 2) { System.Console.WriteLine("Usage: TestCode); return; } long num1 = long.Parse(args[0]); long num2 = long.Parse(args[1]); long sum = AddClass.Add(num1, num2); long product = MultiplyClass.Multiply(num1, num2); System.Console.WriteLine("{0} + {1} = {2}", num1, num2, sum); System.Console.WriteLine("{0} * {1} = {2}", num1, num2, product); } } /* Output (assuming 1234 and 5678 are entered as command line args): Calling methods from MathLibrary.DLL: 1234 + 5678 = 6912 1234 * 5678 = 7006652 */ "