当前位置:  编程技术>.net/c#/asp.net
本页文章导读:
    ▪HoverMenuExtender应用      AjaxControlToolkit控件,当然是在Ajax下应用。在aspx页面或母版页中应该要写上:<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>TargetControlID指定要显示信息的控件,PopupControlID指.........
    ▪分享懒人张RDLC报表(七、八)      来自懒人张:RDLC报表(七)        有关LocalReport、DeviceInfo和PrintDocument的内容已经介绍得差不多了,稍后会给出一个继承自 System.Drawing.Printing.PrintDocument的组件EMFStreamP.........
    ▪[转载] MVC3自定义标签,给Html.ActionLink加上支持图片链接的功能       Html.ActionLink只支持文字链接,现在我们利用C#的扩展方法写一个Html.ActionLinkWithImage()让其支持图片链接的功能。一、首先新建一个静态类,将命名空间在改在System.Web.Mvc下,代码如下代码 .........

[1]HoverMenuExtender应用
    来源:    发布时间: 2013-10-28

AjaxControlToolkit控件,当然是在Ajax下应用。在aspx页面或母版页中应该要写上:

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

TargetControlID指定要显示信息的控件,PopupControlID指定鼠标移动上时显示的信息。

<asp:Label id="Label30" runat="server" ForeColor="Blue" Text="帮助!"></asp:Label>
<cc1:HoverMenuExtender ID="HoverMenuExtender1" runat="server" TargetControlID="Label30" PopupControlID="pMessage" PopupPosition="Right" OffsetX="0" OffsetY="15">
</cc1:HoverMenuExtender>

以下为显示信息的Panel。

<asp:Panel ID="pMessage" runat="server" Css Width="300px">
<div>
<div ><strong>
使用帮助</strong></div>
...
</div>
</asp:Panel>

Css如下:

.HoverMenuStyle
{
filter:alpha(opacity=70); /*IE*/
-moz-opacity:0.7; /*MOZ , FF*/
opacity:0.7; /*CSS3, FF1.5*/
background: #fff6bf;
text-align: left;
padding: 5px;
border: 1px solid #ffd324;
z-index: 1;
color:MenuText;
}

效果图:

本文链接


    
[2]分享懒人张RDLC报表(七、八)
    来源:    发布时间: 2013-10-28

来自懒人张:RDLC报表(七)

        有关LocalReport、DeviceInfo和PrintDocument的内容已经介绍得差不多了,稍后会给出一个继承自 System.Drawing.Printing.PrintDocument的组件EMFStreamPrintDocument。但是现在,来看一下 如何进行自定义纸张票据打印时的页面设置。页面设置窗体如下图所示:

        如何添加、删除自定义大小的纸张、枚举系统的打印机?以前在博客园的一篇随笔中参加过讨论,见http://wormday.cnblogs.com/archive/2005/12/22/302635.aspx。 当然还是使用Win32 API,以下是我封装的一个关于打印机控制的类[以前用VB实现过比这个类还要多的关于打印机控制的功能,但是在C#中感到还是挺困难的,所以这次只给出 了够用的功能:获取当前指定打印机的状态、删除已经存在的自定义纸张、指定的打印机设置以mm为单位的自定义纸张(Form)、获取本地打印机列表、获取 本机的默认打印机名称、设置默认打印机、判断打印机是否在系统可用的打印机列表中、判断表单是否在指定的打印机所支持的纸张列表中、判断指定纸张的宽度和 高度和在文本框中指定的宽度和高度是否匹配、英尺到厘米的转换]:

using System;
using System.Text;
using System.Runtime.InteropServices;
using System.Security;
using System.ComponentModel;
using System.Drawing.Printing;

namespace RDLCReport
{

public class Printer
{
private Printer()
{

}

#region API声明

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
internal struct structPrinterDefaults
{
[MarshalAs(UnmanagedType.LPTStr)]
public String pDatatype;
public IntPtr pDevMode;
[MarshalAs(UnmanagedType.I4)]
public int DesiredAccess;
};

[DllImport("winspool.Drv", EntryPoint = "OpenPrinter", SetLastError = true,
CharSet = CharSet.Unicode, ExactSpelling = false, CallingConvention = CallingConvention.StdCall),
SuppressUnmanagedCodeSecurityAttribute()]
internal static extern bool OpenPrinter([MarshalAs(UnmanagedType.LPTStr)]
string printerName,
out IntPtr phPrinter,
ref structPrinterDefaults pd);

[DllImport("winspool.Drv", EntryPoint = "ClosePrinter", SetLastError = true,
CharSet = CharSet.Unicode, ExactSpelling = false,
CallingConvention = CallingConvention.StdCall), SuppressUnmanagedCodeSecurityAttribute()]
internal static extern bool ClosePrinter(IntPtr phPrinter);

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
internal struct structSize
{
public Int32 width;
public Int32 height;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
internal struct structRect
{
public Int32 left;
public Int32 top;
public Int32 right;
public Int32 bottom;
}

[StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode)]
internal struct FormInfo1
{
[FieldOffset(0), MarshalAs(UnmanagedType.I4)]
public uint Flags;
[FieldOffset(4), MarshalAs(UnmanagedType.LPWStr)]
public String pName;
[FieldOffset(8)]
public structSize Size;
[FieldOffset(16)]
public structRect ImageableArea;
};

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
internal struct structDevMode
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public String
dmDeviceName;
[MarshalAs(UnmanagedType.U2)]
public short dmSpecVersion;
[MarshalAs(UnmanagedType.U2)]
public short dmDriverVersion;
[MarshalAs(UnmanagedType.U2)]
public short dmSize;
[MarshalAs(UnmanagedType.U2)]
public short
    
[3][转载] MVC3自定义标签,给Html.ActionLink加上支持图片链接的功能
    来源:    发布时间: 2013-10-28

 

Html.ActionLink只支持文字链接,现在我们利用C#的扩展方法写一个Html.ActionLinkWithImage()让其支持图片链接的功能。
一、首先新建一个静态类,将命名空间在改在System.Web.Mvc下,代码如下

代码 复制 - 运行

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace System.Web.Mvc
{
public static class MyHelpler
{
public static MvcHtmlString ActionLinkWithImage(this HtmlHelper html, string imgSrc, string actionName)
{
var urlHelper = new UrlHelper(html.ViewContext.RequestContext);

string imgUrl = urlHelper.Content(imgSrc);
TagBuilder imgTagBuilder = new TagBuilder("img");
imgTagBuilder.MergeAttribute("src", imgUrl);
string img = imgTagBuilder.ToString(TagRenderMode.SelfClosing);

string url = urlHelper.Action(actionName);

TagBuilder tagBuilder = new TagBuilder("a")
{
InnerHtml = img
};
tagBuilder.MergeAttribute("href", url);

return new MvcHtmlString(tagBuilder.ToString(TagRenderMode.Normal));
}
public static MvcHtmlString ActionLinkWithImage(this HtmlHelper html, string imgSrc, string actionName,string controllerName,object routeValue=null)
{
var urlHelper = new UrlHelper(html.ViewContext.RequestContext);

string imgUrl = urlHelper.Content(imgSrc);
TagBuilder imgTagBuilder = new TagBuilder("img");
imgTagBuilder.MergeAttribute("src", imgUrl);
string img = imgTagBuilder.ToString(TagRenderMode.SelfClosing);

string url = urlHelper.Action(actionName, controllerName, routeValue);

TagBuilder tagBuilder = new TagBuilder("a")
{
InnerHtml = img
};
tagBuilder.MergeAttribute("href", url);

return new MvcHtmlString(tagBuilder.ToString(TagRenderMode.Normal));
}
}
}


二、在view下使用:

代码 复制 - 运行

@Html.ActionLinkWithImage(Url.Content("~/Content/images/index_1.gif"), "Index")

@Html.ActionLinkWithImage(Url.Content("~/Content/images/index_2.gif"), "List","Admin", new { id=1})

 

原文地址:http://www.cnblogs.com/princeoicq/articles/2405914.html

 

本文链接


    
最新技术文章:
 




特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3