請參考來源:【Jqurey EasyUI+Asp.net】----DataGrid数据绑定,以及增、删、改(SQL)
ASP.NET使用 jQuery EasyUi DataGrid 存取資料
asp.net + easyui框架,一步步学习easyui-datagrid——实现分页和搜索(二)
--
2015年7月30日 星期四
2015年7月29日 星期三
2015年7月28日 星期二
2015年7月27日 星期一
ASP.NET jQuery and Database Driven Accordion
參考引用來源:ASP.NET jQuery and Database Driven Accordion
請參考來源:Building a Database Driven Hierarchical Menu using ASP.NET and SooperFish Jquery Plugin
--
請參考來源:Building a Database Driven Hierarchical Menu using ASP.NET and SooperFish Jquery Plugin
--
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.js" type="text/javascript"></script>
<style type="text/css">
.Menu
{
width: 200px;
text-align: center;
border: solid 2px gray;
padding: 0px;
background-color: Silver;
cursor: hand;
font-weight: bold;
}
.MenuItem
{
width: 192px;
text-align: center;
border: solid 1px silver;
padding: 2px;
background-color: whitesmoke;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
$.ajax(
{
type: "POST",
url: "ASPNET jQuery and Database Driven Accordion.aspx/GetMenus",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: CreateMenus,
error: function(err) {
alert(err.status + " - " + err.statusText);
}
});
});
function CreateMenus(results) {
results = results.d;
for (var i = 0; i < results.length; i++) {
$("<div class='Menu'>" + results[i].Text + "</div>")
.click({ MenuId: results[i].MenuId }, OnMenuClick)
.appendTo("#accordionContainer");
}
}
function OnMenuClick(event) {
$("div[id ^= 'menuItemGroup']").slideUp(500);
$.ajax(
{
type: "POST",
url: "ASPNET jQuery and Database Driven Accordion.aspx/GetMenuItems",
data: '{"menuId":"' + event.data.MenuId + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(items) {
items = items.d;
$(event.target).children().remove();
var html = "<div id='menuItemGroup" + event.data.MenuId + "' style='display:none'>";
for (var j = 0; j < items.length; j++) {
html += "<div class='MenuItem'><a href='" + items[j].NavigateUrl + "'>" +
items[j].Text + "</a></div>";
}
html += "</div>";
$(event.target).append(html);
$("#menuItemGroup" + event.data.MenuId).slideDown(500);
},
error: function(err, r, c) {
alert(err.status + " - " + err.statusText);
}
}
)
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="accordionContainer">
</div>
</form>
</body>
</html>
---
public class Menu
{
public int MenuId { get; set; }
public string Text { get; set; }
}
public class MenuItem
{
public int MenuId { get; set; }
public int MenuItemId { get; set; }
public string Text { get; set; }
public string NavigateUrl { get; set; }
}
public partial class ASPNET_jQuery_and_Database_Driven_Accordion : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[System.Web.Services.WebMethod]
public static System.Collections.Generic.List<Menu> GetMenus()
{
System.Collections.Generic.List<Menu> list = new System.Collections.Generic.List<Menu>();
for (int i = 0; i < 6; i++)
{
list.Add(new Menu() {
MenuId= i,
Text = "Menu text "+i.ToString()
});
}
return list;
}
[System.Web.Services.WebMethod]
public static System.Collections.Generic.List<MenuItem> GetMenuItems(int menuId)
{
Random r = new Random();
System.Collections.Generic.List<MenuItem> list = new System.Collections.Generic.List<MenuItem>();
for (int i = 0; i < r.Next(10); i++)
{
MenuItem mi = new MenuItem();
mi.MenuId = menuId;
mi.MenuItemId = i;
mi.Text = "Menu "+ menuId.ToString()+" --- Menu item "+ i.ToString();
mi.NavigateUrl ="http://www.testmenu.com?menuID="+menuId.ToString()+"&MenuItemID="+i.ToString() ;
list.Add(mi);
}
return list;
}
}
jQuery Menu Hover 效果
var obj = null;
function checkHover() {
if (obj) {
$(obj).find(‘ul’).fadeOut(‘fast’);// 淡出效果
}
}
$(document).ready(function () {
$(‘#Nav >li’).hover(function () { // 移入的函數
if (obj) {
obj.find(‘ul’).fadeOut(‘fast’) // 淡出效果
obj = null
}
$(this).find(‘ul’).fadeIn(‘fast’);
}, function () { // 移出的函數
obj = $(this);
setTimeout("checkHover()", 400);
});
});
HTML :
<body>
<ul id="NAV">
<li >Test1
<ul class="menu">
<li><a href="#1">控制台首頁1</a></li>
<li><a href="#2">編輯個人資料1</a></li>
<li><a href="#3">個人空間管理1</a></li>
</ul>
</li>
<li>Test2
<ul class="menu">
<li><a href="#1">控制台首頁2</a></li>
<li><a href="#2">編輯個人資料2</a></li>
<li><a href="#3">個人空間管理2</a></li>
</ul>
</li>
</ul>
</body>
</html>
CSS :
<style type="text/css">
#NAV {width :100px; padding :0px ; list-style :none}
#NAV li { background : #ddd; margin :1x; height :20px}
.menu {padding :0px; margin-top :-18px ; margin-left :98px ;width :202px;list-style :none; display :none}
.menu li {width :202px ; height :20px}
</style>
Request.Pash去讀取網址後的參數
語 法 結 果
Request.ApplicationPath /
Request.PhysicalPath D:\Projects\Solution\web\minwt\doc\detail.aspx
System.IO.Path.GetDirectoryName
(Request.PhysicalPath) D:\Projects\Solution\web\minwt\doc
Request.PhysicalApplicationPath D:\Projects\Solution\web\
System.IO.Path.GetFileName
(Request.PhysicalPath) detail.aspx
Request.CurrentExecutionFilePath /minwt/doc/detail.aspx
Request.FilePath /minwt/doc/detail.aspx
Request.Path /minwt/doc/detail.aspx/123
Request.RawUrl /minwt/doc/detail.aspx/123?id=1
Request.Url.AbsolutePath /minwt/doc/detail.aspx/123
Request.Url.AbsoluteUri http://localhost/minwt/doc/detail.aspx/123?id=1
Request.Url.Scheme http
Request.Url.Host localhost
Request.Url.Port 1897
Request.Url.Authority localhost:1897
Request.Url.LocalPath /minwt/doc/detail.aspx/123
Request.PathInfo /123
Request.Url.PathAndQuery /minwt/doc/detail.aspx/123?id=1
Request.Url.Query ?id=1
Request.Url.Segments /
minwt/
doc/
detail.aspx/
123
Request.ApplicationPath /
Request.PhysicalPath D:\Projects\Solution\web\minwt\doc\detail.aspx
System.IO.Path.GetDirectoryName
(Request.PhysicalPath) D:\Projects\Solution\web\minwt\doc
Request.PhysicalApplicationPath D:\Projects\Solution\web\
System.IO.Path.GetFileName
(Request.PhysicalPath) detail.aspx
Request.CurrentExecutionFilePath /minwt/doc/detail.aspx
Request.FilePath /minwt/doc/detail.aspx
Request.Path /minwt/doc/detail.aspx/123
Request.RawUrl /minwt/doc/detail.aspx/123?id=1
Request.Url.AbsolutePath /minwt/doc/detail.aspx/123
Request.Url.AbsoluteUri http://localhost/minwt/doc/detail.aspx/123?id=1
Request.Url.Scheme http
Request.Url.Host localhost
Request.Url.Port 1897
Request.Url.Authority localhost:1897
Request.Url.LocalPath /minwt/doc/detail.aspx/123
Request.PathInfo /123
Request.Url.PathAndQuery /minwt/doc/detail.aspx/123?id=1
Request.Url.Query ?id=1
Request.Url.Segments /
minwt/
doc/
detail.aspx/
123
2015年7月22日 星期三
asp.net WebClientPrint 範例
1.How to print multiple files to client printers from ASP.NET
2.Download WebClientPrint for ASP.NET
3.WebClientPrint for ASP.NET 相關資訊
4.How to Print RAW Text Files without Print Dialog from ASP.NET
5.How to print raw ESC/POS commands from ASP.NET directly to the client printer
6.How to print raw Zebra ZPL commands from ASP.NET directly to the client printer
---
2.Download WebClientPrint for ASP.NET
3.WebClientPrint for ASP.NET 相關資訊
4.How to Print RAW Text Files without Print Dialog from ASP.NET
5.How to print raw ESC/POS commands from ASP.NET directly to the client printer
6.How to print raw Zebra ZPL commands from ASP.NET directly to the client printer
---
2015年7月21日 星期二
2015年7月20日 星期一
POS Print in VB.NET ( Raw Print )
參考引用來源:POS Print in VB.NET ( Raw Print )
--
Create new class :
Imports System.IO
Imports System.Drawing.Printing
Imports System.Runtime.InteropServices
Public Class RawPrinterHelper
' Structure and API declarions:
_
Structure DOCINFOW
Public pDocName As String
Public pOutputFile As String
Public pDataType As String
End Structure
SetLastError:=True, CharSet:=CharSet.Unicode, _
ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function OpenPrinter(ByVal src As String, ByRef hPrinter As IntPtr, ByVal pd As Long) As Boolean
End Function
SetLastError:=True, CharSet:=CharSet.Unicode, _
ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function ClosePrinter(ByVal hPrinter As IntPtr) As Boolean
End Function
SetLastError:=True, CharSet:=CharSet.Unicode, _
ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function StartDocPrinter(ByVal hPrinter As IntPtr, ByVal level As Int32, ByRef pDI As DOCINFOW) As Boolean
End Function
SetLastError:=True, CharSet:=CharSet.Unicode, _
ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function EndDocPrinter(ByVal hPrinter As IntPtr) As Boolean
End Function
SetLastError:=True, CharSet:=CharSet.Unicode, _
ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function StartPagePrinter(ByVal hPrinter As IntPtr) As Boolean
End Function
SetLastError:=True, CharSet:=CharSet.Unicode, _
ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function EndPagePrinter(ByVal hPrinter As IntPtr) As Boolean
End Function
SetLastError:=True, CharSet:=CharSet.Unicode, _
ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function WritePrinter(ByVal hPrinter As IntPtr, ByVal pBytes As IntPtr, ByVal dwCount As Int32, ByRef dwWritten As Int32) As Boolean
End Function
' SendBytesToPrinter()
' When the function is given a printer name and an unmanaged array of
' bytes, the function sends those bytes to the print queue.
' Returns True on success or False on failure.
Public Shared Function SendBytesToPrinter(ByVal szPrinterName As String, ByVal pBytes As IntPtr, ByVal dwCount As Int32) As Boolean
Dim hPrinter As IntPtr ' The printer handle.
Dim dwError As Int32 ' Last error - in case there was trouble.
Dim di As DOCINFOW ' Describes your document (name, port, data type).
Dim dwWritten As Int32 ' The number of bytes written by WritePrinter().
Dim bSuccess As Boolean ' Your success code.
' Set up the DOCINFO structure.
With di
.pDocName = "My Visual Basic .NET RAW Document"
.pDataType = "RAW"
End With
' Assume failure unless you specifically succeed.
bSuccess = False
If OpenPrinter(szPrinterName, hPrinter, 0) Then
If StartDocPrinter(hPrinter, 1, di) Then
If StartPagePrinter(hPrinter) Then
' Write your printer-specific bytes to the printer.
bSuccess = WritePrinter(hPrinter, pBytes, dwCount, dwWritten)
EndPagePrinter(hPrinter)
End If
EndDocPrinter(hPrinter)
End If
ClosePrinter(hPrinter)
End If
' If you did not succeed, GetLastError may give more information
' about why not.
If bSuccess = False Then
dwError = Marshal.GetLastWin32Error()
End If
Return bSuccess
End Function ' SendBytesToPrinter()
' SendFileToPrinter()
' When the function is given a file name and a printer name,
' the function reads the contents of the file and sends the
' contents to the printer.
' Presumes that the file contains printer-ready data.
' Shows how to use the SendBytesToPrinter function.
' Returns True on success or False on failure.
Public Shared Function SendFileToPrinter(ByVal szPrinterName As String, ByVal szFileName As String) As Boolean
' Open the file.
Dim fs As New FileStream(szFileName, FileMode.Open)
' Create a BinaryReader on the file.
Dim br As New BinaryReader(fs)
' Dim an array of bytes large enough to hold the file's contents.
Dim bytes(fs.Length) As Byte
Dim bSuccess As Boolean
' Your unmanaged pointer.
Dim pUnmanagedBytes As IntPtr
' Read the contents of the file into the array.
bytes = br.ReadBytes(fs.Length)
' Allocate some unmanaged memory for those bytes.
pUnmanagedBytes = Marshal.AllocCoTaskMem(fs.Length)
' Copy the managed byte array into the unmanaged array.
Marshal.Copy(bytes, 0, pUnmanagedBytes, fs.Length)
' Send the unmanaged bytes to the printer.
bSuccess = SendBytesToPrinter(szPrinterName, pUnmanagedBytes, fs.Length)
' Free the unmanaged memory that you allocated earlier.
Marshal.FreeCoTaskMem(pUnmanagedBytes)
Return bSuccess
End Function ' SendFileToPrinter()
' When the function is given a string and a printer name,
' the function sends the string to the printer as raw bytes.
Public Shared Function SendStringToPrinter(ByVal szPrinterName As String, ByVal szString As String)
Dim pBytes As IntPtr
Dim dwCount As Int32
' How many characters are in the string?
dwCount = szString.Length()
' Assume that the printer is expecting ANSI text, and then convert
' the string to ANSI text.
pBytes = Marshal.StringToCoTaskMemAnsi(szString)
' Send the converted ANSI string to the printer.
SendBytesToPrinter(szPrinterName, pBytes, dwCount)
Marshal.FreeCoTaskMem(pBytes)
End Function
End Class
How to using the class ?
Public Sub PrintingOut()
Dim s As String
Dim pd As New PrintDialog()
' You need a string to send.
s = "Hello, this is a test"
' Open the printer dialog box, and then allow the user to select a printer.
pd.PrinterSettings = New PrinterSettings()
If (pd.ShowDialog() = DialogResult.OK) Then
RawPrinterHelper.SendStringToPrinter(pd.PrinterSettings.PrinterName, s)
End If
End Sub
Varible “s” can be assign POS code, this is example :
Public sess_ESC As String = ChrW(27) + "!"
Public sess_EPSON_BOLD_ON As String = sess_ESC + Chr(16) + sess_ESC + Chr(32)
Public sess_EPSON_BOLD_OFF As String = sess_ESC + Chr(0) + sess_ESC + Chr(0)
Public sess_STAR_BOLD_ON As String = sess_ESC + Chr(14) + sess_ESC + Chr(15)
Public sess_STAR_BOLD_OFF As String = sess_ESC + Chr(4) + sess_ESC + Chr(5)
Public sess_PRINT_BOLD_ON As String = sess_ESC + Chr(17)
Public sess_PRINT_BOLD_OFF As String = sess_ESC + Chr(0)
Example making bold text :
s = " .: Parking System :. " & vbCrLf
s &= dtInfo(1) & vbCrLf
s &= dtInfo(2) & ", " & dtInfo(3) & vbCrLf
s &= dtInfo(5) & vbCrLf
s &= "================================" & vbCrLf
s &= " GATE OPERATOR " & vbCrLf
s &= " " & sess_gate & " " & sess_fullname & " - " & sess_username & vbCrLf
s &= "IN : " & dtTable(6) & vbCrLf
s &= " " & dtTable(0) & vbCrLf
's &= FontStyle.Bold
s &= sess_PRINT_BOLD_ON
s &= " " & dtTable(1) & vbCrLf
s &= " Rp. " & Format(total, "#,##0.00") & vbCrLf
s &= sess_PRINT_BOLD_OFF
s &= "OUT : " & getnow & vbCrLf
s &= " " & dtTable(12) & vbCrLf
s &= " " & dtTable(2) & vbCrLf
s &= "================================" & vbCrLf
s &= "Terima Kasih Atas Kunjungan Anda" & vbCrLf
s &= "" & vbCrLf
s &= "" & vbCrLf
s &= "" & vbCrLf
s &= "" & vbCrLf
s &= "" & vbCrLf
s &= "" & vbCrLf
s &= "" & vbCrLf
s &= "" & vbCrLf
s &= "_" & vbCrLf
--
Create new class :
Imports System.IO
Imports System.Drawing.Printing
Imports System.Runtime.InteropServices
Public Class RawPrinterHelper
' Structure and API declarions:
Structure DOCINFOW
End Structure
ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function OpenPrinter(ByVal src As String, ByRef hPrinter As IntPtr, ByVal pd As Long) As Boolean
End Function
ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function ClosePrinter(ByVal hPrinter As IntPtr) As Boolean
End Function
ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function StartDocPrinter(ByVal hPrinter As IntPtr, ByVal level As Int32, ByRef pDI As DOCINFOW) As Boolean
End Function
ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function EndDocPrinter(ByVal hPrinter As IntPtr) As Boolean
End Function
ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function StartPagePrinter(ByVal hPrinter As IntPtr) As Boolean
End Function
ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function EndPagePrinter(ByVal hPrinter As IntPtr) As Boolean
End Function
ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function WritePrinter(ByVal hPrinter As IntPtr, ByVal pBytes As IntPtr, ByVal dwCount As Int32, ByRef dwWritten As Int32) As Boolean
End Function
' SendBytesToPrinter()
' When the function is given a printer name and an unmanaged array of
' bytes, the function sends those bytes to the print queue.
' Returns True on success or False on failure.
Public Shared Function SendBytesToPrinter(ByVal szPrinterName As String, ByVal pBytes As IntPtr, ByVal dwCount As Int32) As Boolean
Dim hPrinter As IntPtr ' The printer handle.
Dim dwError As Int32 ' Last error - in case there was trouble.
Dim di As DOCINFOW ' Describes your document (name, port, data type).
Dim dwWritten As Int32 ' The number of bytes written by WritePrinter().
Dim bSuccess As Boolean ' Your success code.
' Set up the DOCINFO structure.
With di
.pDocName = "My Visual Basic .NET RAW Document"
.pDataType = "RAW"
End With
' Assume failure unless you specifically succeed.
bSuccess = False
If OpenPrinter(szPrinterName, hPrinter, 0) Then
If StartDocPrinter(hPrinter, 1, di) Then
If StartPagePrinter(hPrinter) Then
' Write your printer-specific bytes to the printer.
bSuccess = WritePrinter(hPrinter, pBytes, dwCount, dwWritten)
EndPagePrinter(hPrinter)
End If
EndDocPrinter(hPrinter)
End If
ClosePrinter(hPrinter)
End If
' If you did not succeed, GetLastError may give more information
' about why not.
If bSuccess = False Then
dwError = Marshal.GetLastWin32Error()
End If
Return bSuccess
End Function ' SendBytesToPrinter()
' SendFileToPrinter()
' When the function is given a file name and a printer name,
' the function reads the contents of the file and sends the
' contents to the printer.
' Presumes that the file contains printer-ready data.
' Shows how to use the SendBytesToPrinter function.
' Returns True on success or False on failure.
Public Shared Function SendFileToPrinter(ByVal szPrinterName As String, ByVal szFileName As String) As Boolean
' Open the file.
Dim fs As New FileStream(szFileName, FileMode.Open)
' Create a BinaryReader on the file.
Dim br As New BinaryReader(fs)
' Dim an array of bytes large enough to hold the file's contents.
Dim bytes(fs.Length) As Byte
Dim bSuccess As Boolean
' Your unmanaged pointer.
Dim pUnmanagedBytes As IntPtr
' Read the contents of the file into the array.
bytes = br.ReadBytes(fs.Length)
' Allocate some unmanaged memory for those bytes.
pUnmanagedBytes = Marshal.AllocCoTaskMem(fs.Length)
' Copy the managed byte array into the unmanaged array.
Marshal.Copy(bytes, 0, pUnmanagedBytes, fs.Length)
' Send the unmanaged bytes to the printer.
bSuccess = SendBytesToPrinter(szPrinterName, pUnmanagedBytes, fs.Length)
' Free the unmanaged memory that you allocated earlier.
Marshal.FreeCoTaskMem(pUnmanagedBytes)
Return bSuccess
End Function ' SendFileToPrinter()
' When the function is given a string and a printer name,
' the function sends the string to the printer as raw bytes.
Public Shared Function SendStringToPrinter(ByVal szPrinterName As String, ByVal szString As String)
Dim pBytes As IntPtr
Dim dwCount As Int32
' How many characters are in the string?
dwCount = szString.Length()
' Assume that the printer is expecting ANSI text, and then convert
' the string to ANSI text.
pBytes = Marshal.StringToCoTaskMemAnsi(szString)
' Send the converted ANSI string to the printer.
SendBytesToPrinter(szPrinterName, pBytes, dwCount)
Marshal.FreeCoTaskMem(pBytes)
End Function
End Class
How to using the class ?
Public Sub PrintingOut()
Dim s As String
Dim pd As New PrintDialog()
' You need a string to send.
s = "Hello, this is a test"
' Open the printer dialog box, and then allow the user to select a printer.
pd.PrinterSettings = New PrinterSettings()
If (pd.ShowDialog() = DialogResult.OK) Then
RawPrinterHelper.SendStringToPrinter(pd.PrinterSettings.PrinterName, s)
End If
End Sub
Varible “s” can be assign POS code, this is example :
Public sess_ESC As String = ChrW(27) + "!"
Public sess_EPSON_BOLD_ON As String = sess_ESC + Chr(16) + sess_ESC + Chr(32)
Public sess_EPSON_BOLD_OFF As String = sess_ESC + Chr(0) + sess_ESC + Chr(0)
Public sess_STAR_BOLD_ON As String = sess_ESC + Chr(14) + sess_ESC + Chr(15)
Public sess_STAR_BOLD_OFF As String = sess_ESC + Chr(4) + sess_ESC + Chr(5)
Public sess_PRINT_BOLD_ON As String = sess_ESC + Chr(17)
Public sess_PRINT_BOLD_OFF As String = sess_ESC + Chr(0)
Example making bold text :
s = " .: Parking System :. " & vbCrLf
s &= dtInfo(1) & vbCrLf
s &= dtInfo(2) & ", " & dtInfo(3) & vbCrLf
s &= dtInfo(5) & vbCrLf
s &= "================================" & vbCrLf
s &= " GATE OPERATOR " & vbCrLf
s &= " " & sess_gate & " " & sess_fullname & " - " & sess_username & vbCrLf
s &= "IN : " & dtTable(6) & vbCrLf
s &= " " & dtTable(0) & vbCrLf
's &= FontStyle.Bold
s &= sess_PRINT_BOLD_ON
s &= " " & dtTable(1) & vbCrLf
s &= " Rp. " & Format(total, "#,##0.00") & vbCrLf
s &= sess_PRINT_BOLD_OFF
s &= "OUT : " & getnow & vbCrLf
s &= " " & dtTable(12) & vbCrLf
s &= " " & dtTable(2) & vbCrLf
s &= "================================" & vbCrLf
s &= "Terima Kasih Atas Kunjungan Anda" & vbCrLf
s &= "" & vbCrLf
s &= "" & vbCrLf
s &= "" & vbCrLf
s &= "" & vbCrLf
s &= "" & vbCrLf
s &= "" & vbCrLf
s &= "" & vbCrLf
s &= "" & vbCrLf
s &= "_" & vbCrLf
2015年7月12日 星期日
ASP.NET Client-side cross-browser barcode thermal label printing with ThermalLabel SDK
官網:ASP.NET Client-side cross-browser barcode thermal label printing with ThermalLabel SDK
--
這是一個提供client 列印條碼(and read Client printer list) 的SDK
看這寫法,像是讓client sned printer to server
有興趣的,可以研究一下
我不大喜歡安裝其他外掛來達到需求
--
這是一個提供client 列印條碼(and read Client printer list) 的SDK
看這寫法,像是讓client sned printer to server
有興趣的,可以研究一下
我不大喜歡安裝其他外掛來達到需求
2015年7月10日 星期五
SQL Server 瀏覽 trc 檔 (Log)
請參考來源
--
(1)
Example:
SELECT *
FROM fn_trace_getinfo(1)
(2)
SELECT T.eventid AS [id], E.name
FROM fn_trace_geteventinfo(1) T
JOIN sys.trace_events E
ON T.eventid = E.trace_event_id
GROUP BY T.eventid, E.name
(3)
SELECT *
FROM fn_trace_gettable
('C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\log.trc', default)
--
(1)
Example:
SELECT *
FROM fn_trace_getinfo(1)
(2)
SELECT T.eventid AS [id], E.name
FROM fn_trace_geteventinfo(1) T
JOIN sys.trace_events E
ON T.eventid = E.trace_event_id
GROUP BY T.eventid, E.name
(3)
SELECT *
FROM fn_trace_gettable
('C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\log.trc', default)
Javascript呼叫IE列印以及預覽列印的方法
引用來源
--
--
整頁列印:
html部分:
<INPUT TYPE="button" value="整頁列印" onclick="print()">
Javascript部分:
N/A
部分列印(只列印div包起來的網頁):
html部分:
<div id="block">
<P><img id="ruten" name="ruten" SRC="http://www.ruten.com.tw/imgs/2008/logo.gif"></P>
</div>
<input type="button" value="部分列印" onclick="printScreen(block)">
Javascript部分:
//列印div包起來的部分並且列印完畢後自動關閉列印網頁
function printScreen(block){
var value = block.innerHTML;
var printPage = window.open("","printPage","");
printPage.document.open();
printPage.document.write("<HTML><head></head><BODY onload='window.print();window.close()'>");
printPage.document.write("<PRE>");
printPage.document.write(value);
printPage.document.write("</PRE>");
printPage.document.close("</BODY></HTML>");
}
整頁預覽列印:
html部分:
<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=0></OBJECT>
<INPUT TYPE="button" value="整頁預覽" onclick="javascript:wb.execwb(7,1)">
Javascript部分:
N/A
部分預覽列印(只預覽div包起來的部份):
html部分:
<div id="block">
<P><img id="ruten" name="ruten" SRC="http://www.ruten.com.tw/imgs/2008/logo.gif"></P></div>
<input type="button" value="區塊預覽" onclick="previewScreen(block)">
Javascript部分:
//預覽div包起來的部分並且列印完畢後自動關閉列印網頁
function previewScreen(block){
var value = block.innerHTML;
var printPage = window.open("","printPage","");
printPage.document.open();
printPage.document.write("<OBJECT classid='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2' height=0 id=wc name=wc width=0></OBJECT>");
printPage.document.write("<HTML><head></head><BODY onload='javascript:wc.execwb(7,1);window.close()'>");
printPage.document.write("<PRE>");
printPage.document.write(value);
printPage.document.write("</PRE>");
printPage.document.close("</BODY></HTML>");
}
asp.net 列印網頁
asp.net 列印網頁
方法一:透過 webbrowser 物件
document.all.WebBrowser.ExecWB(1,1) //打開
document.all.WebBrowser.ExecWB(2,1) //關閉全部
document.all.WebBrowser.ExecWB(4,1) //另存為
document.all.WebBrowser.ExecWB(6,1) //列印
document.all.WebBrowser.ExecWB(6,6) //直接列印
document.all.WebBrowser.ExecWB(7,1) //預覽列印
document.all.WebBrowser.ExecWB(8,1) //頁面設置
document.all.WebBrowser.ExecWB(10,1) //屬性
document.all.WebBrowser.ExecWB(17,1) //全選
document.all.WebBrowser.ExecWB(22,1) //刷新
document.all.WebBrowser.ExecWB(45,1) //關閉
方法二:直接用 javascript
window.print();
方法三:寫一個JS檔,搭配前端 button 的觸發,列印指定 DIV 的區塊
<title>列印頁面測試</title>
<script type="text/javascript" src="print.js"></script>
</head>
<asp:Button ID="Button1" runat="server" Text="Button" Height="61px" onclientclick="printScreen(print_parts)" Width="248px" onclick="Button1_Click" />
print.js
function printScreen(printlist)
{
var value = printlist.innerHTML;
var printPage = window.open("", "Printing...", "");
printPage.document.open();
printPage.document.write("<HTML><head></head><BODY onload='window.print();window.close()'>");
printPage.document.write("<PRE>");
printPage.document.write(value);
printPage.document.write("</PRE>");
printPage.document.close("</BODY></HTML>");
}
protected void Button1_Click(object sender, EventArgs e)
{
Page.ClientScript.RegisterClientScriptInclude("myPrint", "print.js");
}
2015年7月9日 星期四
2015年7月6日 星期一
2015年7月4日 星期六
ASP.NET 即時產生縮圖
參考引用來源:[ASP.NET] 即時產生縮圖
--
需求:傳入圖片網址,產生即時縮圖。
可依需求做在一隻檔案裡面 .. 有需要就傳值給它去處理。 (這隻檔案 ContentType 會是 image/Jpeg)
需 Import 進下列 Namespace:
Imports System.Drawing
Imports System.Net
Imports System.IO
Imports System.Web
'''
''' 不儲存縮圖的即時繪製縮圖方法
'''
''' 圖檔網址
''' 寬
''' 高
'''
'''
Public Function renderThumb(ByVal durl As String, ByVal w As Integer, ByVal h As Integer)
Dim width, height As Integer
Dim wc As WebClient = New WebClient()
Dim ms As MemoryStream = New MemoryStream(wc.DownloadData(durl))
Dim image As System.Drawing.Image = New Bitmap(ms)
width = image.Width
height = image.Height
If Not (width < w And height < h) Then
If width > height Then
h = w * height / width
Else
w = h * width / height
End If
End If
Dim img As System.Drawing.Bitmap = New System.Drawing.Bitmap(w, h)
Dim graphic As Graphics = Graphics.FromImage(img)
graphic.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality
graphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
graphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
graphic.DrawImage(image, 0, 0, w, h)
image.Dispose()
Dim ms_r As New System.IO.MemoryStream()
img.Save(ms_r, System.Drawing.Imaging.ImageFormat.Jpeg)
HttpContext.Current.Response.ClearContent()
HttpContext.Current.Response.ContentType = "image/Jpeg"
HttpContext.Current.Response.BinaryWrite(ms_r.ToArray())
img.Dispose()
graphic.Dispose()
End Function
--
需求:傳入圖片網址,產生即時縮圖。
可依需求做在一隻檔案裡面 .. 有需要就傳值給它去處理。 (這隻檔案 ContentType 會是 image/Jpeg)
需 Import 進下列 Namespace:
Imports System.Drawing
Imports System.Net
Imports System.IO
Imports System.Web
'''
''' 不儲存縮圖的即時繪製縮圖方法
'''
''' 圖檔網址
''' 寬
''' 高
'''
'''
Public Function renderThumb(ByVal durl As String, ByVal w As Integer, ByVal h As Integer)
Dim width, height As Integer
Dim wc As WebClient = New WebClient()
Dim ms As MemoryStream = New MemoryStream(wc.DownloadData(durl))
Dim image As System.Drawing.Image = New Bitmap(ms)
width = image.Width
height = image.Height
If Not (width < w And height < h) Then
If width > height Then
h = w * height / width
Else
w = h * width / height
End If
End If
Dim img As System.Drawing.Bitmap = New System.Drawing.Bitmap(w, h)
Dim graphic As Graphics = Graphics.FromImage(img)
graphic.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality
graphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
graphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
graphic.DrawImage(image, 0, 0, w, h)
image.Dispose()
Dim ms_r As New System.IO.MemoryStream()
img.Save(ms_r, System.Drawing.Imaging.ImageFormat.Jpeg)
HttpContext.Current.Response.ClearContent()
HttpContext.Current.Response.ContentType = "image/Jpeg"
HttpContext.Current.Response.BinaryWrite(ms_r.ToArray())
img.Dispose()
graphic.Dispose()
End Function
2015年7月2日 星期四
2015年7月1日 星期三
asp.net 動態產生CheckBox
參考引用來源
--
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Public Partial Class Default4
Inherits System.Web.UI.Page
Private WorkMch As String() = {"A", "B", "C", "D", "E", "F", _
"G", "H"}
'CheckBox的Text
Private Sub Page_Load(sender As Object, e As System.EventArgs) Handles Page.Load
If Not IsPostBack Then
AddControls()
End If
End Sub
Protected Overrides Sub LoadViewState(savedState As Object)
MyBase.LoadViewState(savedState)
'ViewState["controsladded"]似乎是由base繼承下來的,不可更改
If ViewState("controsladded") Is Nothing Then
AddControls()
End If
End Sub
Private Sub AddControls()
pnlCheckbox.Controls.Add(New LiteralControl("
Dim i As Integer = 0
While i < WorkMch.Length
Dim l_cbx As New CheckBox()
l_cbx.Text = WorkMch(i).ToString()
l_cbx.ID = "cbx" + WorkMch(i).ToString()
l_cbx.AutoPostBack = True
'pnlCheckbox為Panel控制項
pnlCheckbox.Controls.Add(New LiteralControl(""))
pnlCheckbox.Controls.Add(l_cbx)
pnlCheckbox.Controls.Add(New LiteralControl("
"))
If i > 0 AndAlso i Mod 4 = 3 AndAlso i <> WorkMch.Length - 1 Then
pnlCheckbox.Controls.Add(New LiteralControl("
"))
ElseIf i = WorkMch.Length - 1 Then
pnlCheckbox.Controls.Add(New LiteralControl("
")) End If
'為自訂的checkbox掛上event
AddHandler l_cbx.CheckedChanged, New EventHandler(AddressOf(l_cbx_CheckedChanged))
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
pnlCheckbox.Controls.Add(New LiteralControl("
")) ViewState("controlsadded") = True
End Sub
Private Sub l_cbx(sender As Object, e As System.EventArgs) Handles l.cbx
Dim cbx As CheckBox = CType(sender, CheckBox)
Response.Write("CheckBox" + cbx.Text + " : " + cbx.Checked.ToString())
End Sub
Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
Dim cbxA As New CheckBox()
cbxA = CType(pnlCheckbox.FindControl("cbxA"), CheckBox)
Response.Write(cbxA.Checked)
End Sub
Protected Sub Button2_Click(sender As Object, e As System.EventArgs) Handles Button2.Click
pnlCheckbox.Controls.Clear()
End Sub
End Class
--
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Public Partial Class Default4
Inherits System.Web.UI.Page
Private WorkMch As String() = {"A", "B", "C", "D", "E", "F", _
"G", "H"}
'CheckBox的Text
Private Sub Page_Load(sender As Object, e As System.EventArgs) Handles Page.Load
If Not IsPostBack Then
AddControls()
End If
End Sub
Protected Overrides Sub LoadViewState(savedState As Object)
MyBase.LoadViewState(savedState)
'ViewState["controsladded"]似乎是由base繼承下來的,不可更改
If ViewState("controsladded") Is Nothing Then
AddControls()
End If
End Sub
Private Sub AddControls()
pnlCheckbox.Controls.Add(New LiteralControl("
Dim i As Integer = 0
While i < WorkMch.Length
Dim l_cbx As New CheckBox()
l_cbx.Text = WorkMch(i).ToString()
l_cbx.ID = "cbx" + WorkMch(i).ToString()
l_cbx.AutoPostBack = True
'pnlCheckbox為Panel控制項
pnlCheckbox.Controls.Add(New LiteralControl("
pnlCheckbox.Controls.Add(l_cbx)
pnlCheckbox.Controls.Add(New LiteralControl("
"))
If i > 0 AndAlso i Mod 4 = 3 AndAlso i <> WorkMch.Length - 1 Then
pnlCheckbox.Controls.Add(New LiteralControl("
pnlCheckbox.Controls.Add(New LiteralControl("
")) End If
'為自訂的checkbox掛上event
AddHandler l_cbx.CheckedChanged, New EventHandler(AddressOf(l_cbx_CheckedChanged))
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
pnlCheckbox.Controls.Add(New LiteralControl("
")) ViewState("controlsadded") = True
End Sub
Private Sub l_cbx(sender As Object, e As System.EventArgs) Handles l.cbx
Dim cbx As CheckBox = CType(sender, CheckBox)
Response.Write("CheckBox" + cbx.Text + " : " + cbx.Checked.ToString())
End Sub
Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
Dim cbxA As New CheckBox()
cbxA = CType(pnlCheckbox.FindControl("cbxA"), CheckBox)
Response.Write(cbxA.Checked)
End Sub
Protected Sub Button2_Click(sender As Object, e As System.EventArgs) Handles Button2.Click
pnlCheckbox.Controls.Clear()
End Sub
End Class
訂閱:
文章 (Atom)