Jun 282013
 

转自:http://www.uisdc.com/buttons-dialog

banner

开篇

layq :确认框,顾名思义,就是对用户的关键行为进行确认。比如在Windows操作系统中,删除某个文件的时候,都会询问“确实要把此文件放入回收站吗?”,用户可以选择“是”或“否”。
大家对于确认框的感觉大抵如此,觉得非常多余,打断了我的操作。这就像我着急上厕所,却被告知要先收费一样让人不爽。不能否认,确认框是一种打断,有时甚至是打扰。
所以这里要把握住一个原则:能不用确认框就尽量不要用。除非用户的操作具有很大的风险,一定需要他来确认一下。

Continue reading »

 Posted by at 9:01 pm
Dec 142007
 

现在已经可以通过Google提供的API,读取到相册的XML文档了,同时做到用XSL解析数据,并且绑定到DataList中去。

相册首页和每个子相册的Thumbmail页基本都绑定成功了,下一步需要对每个图片的页面做解析,看起来难度不小啊。

 Posted by at 5:38 pm
Dec 212006
 

I recently put together a VPC of the BizTalk 2006 RTM on Windows Server 2003. I followed the installation guide and I had no problems during the installation or configuration.
A few days later, during an impromptu sales demo I was asked to show how you would set up an orchestration to call a web service. I didn’t have a local web service so I fired up VS 2005 to create one – only to discover that I couldn’t find the Web Services project template. Why? Because it is only installed when you install the ‘Web Developer’ component of VS 2005; you are told to clear all checkboxes but C# in the installation guide (although to be fair, in the context verbiage above this instruction it does say you need to install C# at a minimum.)
So, if you need to develop web services and your installing BizTalk by following the single-machine Windows Server 2003 installation guide, make sure you check the ‘Web Developer’ component during the VS 2005 installation.
Also, try not to demo things that you haven’t run through previously
[Note that the same instructions appear in the Windows XP installation guide.]

 Posted by at 6:25 am
Sep 262006
 

[code=c#]
public class LimitedBoundField : BoundField
{
private int _characterLimit = 0;
public int CharacterLimit
{
get { return _characterLimit; }
set { _characterLimit = value; }
}
public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
{
base.InitializeCell(cell, cellType, rowState, rowIndex);
if (rowState == DataControlRowState.Edit && cellType == DataControlCellType.DataCell)
{
TextBox tb = ((TextBox)cell.Controls[0]);
tb.MaxLength = _characterLimit;
tb.Text = tb.Text.Substring(0, (tb.Text.Length > _characterLimit) ? _characterLimit : tb.Text.Length);
}
}
} [/code]

 Posted by at 9:08 am
Jul 182006
 

这两天公司里做一个项目,用了很多用户自定义控件,在通过自定义控件更新数据库内容的时候,需要刷新parent页面上的TreeView。 想了好久也没找到trigger parent页面上的method的方法。后来花了很多时间,总算在google上找到了一个[url=http://forums.asp.net/thread/1148078.aspx]帖子[/url](作者是[b]sbyard[/b] from North Yorkshire – England ),解决了我的问题。

干脆把代码贴上来吧
User Control WUC
[code=c#]
<%@ Control Language="C#" ClassName="WUC_Test" %>

Click to Raise event. Send:
Reply

Direct Call Text?

[/code]
Parent Page
[code=c#]
<%@ Page Language="C#" %>
<%@ Register Src="WUC_Test.ascx" TagName="WUC_Test" TagPrefix="uc1" %>




Untitled Page

Event Driven

Message from WUC ?

Direct Method invocation


Send This Text to WUC



[/code]

 Posted by at 10:17 am
Jun 072006
 

[align=center][/align]
[b][color=Orange]Introduction[/color][/b]
Hi, this is my first attempt at an article for CodeProject. I’ve used enough of other peoples so thought I better give something back. I’ve been developing websites for the last 6 years or so doing everything from PHP to C#.NET. For other examples please visit the development section on http://www.chemlock.co.uk/. The project below is ASP.NET in C#. There was a need to display a simple bar per row in the datagrid to quickly illustrate an amount. This is very simple so I’ve set it to beginner level. Any questions please mail me.

[b]Graph display in datagrids[/b]
This morning I had the pleasure of re-writing a consultants code into something which worked and was open to development. For some strange reason this guy wrote all his code in classic ASP hard coding the database connection strings into a file and creating all the SQL on the fly. This was slow. Not only because it was Classic ASP and the SQL strings were constantly changing so the server couldn’t cache the query but because it was badly written. One page got passed two variables in the http request stream and then used those variables to pull the same two values back from the database. Pointless and time consuming. Anyway the results where thrown into tables and one column on all the tables was a graph to show the amount of time booked to a project per week. This was out of a maximum of 60 hours (Don’t know which fool is doing those hours). My friend the highly paid consultant had done this by making a table within a table cell with a width equal to the amount of hours. This meant that if you have booked 34 hours to a project the graph would be 34 pixels long.

I was asked to fix some of the SQL as the results where not very relevant for one of the reports but thought it would be a fairly quick and simple job to simply move the lot to .Net and Stored Procs. So here is my quick and dirty guide to creating a graph column in a datagrid. It’s all nice and basic(C# actually), certainly not rocket science.

First of all Create a nice clean WebForm Here is the code behind.

[code=c#]private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
if(Request[”EmployeeNo”] != null)
{
Db db = new Db();
ArrayList parameters = new ArrayList();
parameters.Add(new DbParameter(”@EmployeeNo”,DbType.String,10,”EmployeeNo”,Request[”EmployeeNo”].ToString()));
Session[”dataset”] = db.GetDataSet(”GetEmployeeBookings”,parameters);
Session[”SortOn”] = “EndDate”;
Session[”SortDirection”] = ” DESC”;
}
}
BindGrid();
} [/code]

Ok so here notice that I’m using a class called DB to get at my database and create a dataset. Use what you like here the main point is to end up with a dataset of your results. I also set up initial Sort Parameters for my datagrid and the initial direction they will be sorted in. Every post back gets the grid bound with data but only the initial pass gets the data from the Database. Obviously if this data was likely to be changed as a result of any page action I would move this database call to a seperate methods but as it’s a static report and I’m in a hurry I’ve left it as I initially did it.

[code=c#]private void BindGrid()
{
if (Session[”dataset”] != null)
{
DataTable dt = ((DataSet)Session[”dataset”]).Tables[0];
DataView dv = dt.DefaultView;
dv.Sort = Session[”SortOn”].ToString() + Session[”SortDirection”].ToString();
this.DataGrid1.DataSource = dv;
this.DataGrid1.DataBind();
} [/code]

Here is the BindGrid method. It first checks that something exists in the Session variable. If it does it extracts it creates a dataview sorted correctly and then binds that to our DataGrid control. Notice how very lazy I’ve been with my DataGrid naming. Remeber this was quick and dirty.

[code=c#]private void DataGrid1_SortCommand(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
{
Session[”SortOn”] = e.SortExpression.ToString();
if (Session[”SortDirection”] == null || Session[”SortDirection”].ToString() == ” ASC”)
{
Session[”SortDirection”] = ” DESC”;
}
else
{
Session[”SortDirection”] = ” ASC”;
}
this.DataGrid1.CurrentPageIndex = 0;
BindGrid();
} [/code]

Here is a nice and standard Sort Event Method. Basically if you select a column heading that has already been selected it will change the direction of that column. Any other column and the grid gets sorted on the new column heading.

[code=c#]private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
decimal hours = decimal.Parse(e.Item.Cells[3].Text);
decimal percentage = (100m / 60m) * hours;
e.Item.Cells[4].Text = “

“;}
} [/code]

This is where the graph is built. In my on-going quest to get shot of tables where tables shouldn’t be I’ve gone for a “DIV” approach. Firstly I create a div that fills the entire cell. Then inside this I create a div that takes up a percentage of the parent div. Please note that without the height command the graph will not show in Firefox. So I’ve got my 60 hours and then work out a percentage of this for the width of the child div. The code is set to apply this when each line of the datagrid gets databound. Each time the hours is worked out from another column in the database (In this instance column 3) and Parsed to a decimal. The resultant html code is injected into the cell 4. All this is set to only occur when the datagrid item (or row) is an Item or Alternating item type, after all we don’t want to create a graph for the header or pager section.

So there we have it very quick and very dirty but it does the trick.

As I said at the start fairly simple, if my description has complicated things then please let me know. Other examples on www.chemlock.co.uk

 Posted by at 2:20 pm
May 072006
 

突然想到一个问题,既然asp.net提供了WebControl,功能又那么强大,接口又那么统一,为什么还要用HTMLControl呢?
Google上找了一下,中文结果几乎完全统一:http://www.google.com/search?hl=zh-CN&inlang=zh-CN&newwindow=1&q=htmlcontrol+webcontrol&lr=lang_zh-CN%7Clang_zh-TW

[quote]Web控件和Html控件虽然好多功能相同并且长得很像

但是它们的内部实现机制是完全不一样的

Web控件要比Html控件执行效率要好

1. 使用起来也相当方便,举个简单的例子,例如Button的生成:

Html控件是将庞大控件集合全部弄到页面中,用到哪个功能,就设置一下属性,如下:

这样会占用相当大的控件资源

Web控件是将集成式的拆解成单功能的:

这样就可以节省不必要的控件所占用的资源了

2.Web控件具有回送功能,能够用ViewState维持控件的状态.

Html控件则不能,当点击页面的操作,其状态就会丢失.

可以做这样的一个实验:

I. 分别建立两个文件: a.html b.aspx

II.在a.html页面中加Html控件的RadioButton和一个button,在b.aspx中加Web控件的adioButton和一个button

III.a.html直接双击浏览器运行,b.aspx通过IIS运行

IV.在a.html运行界面中,选中RadioButton,再单击Button按钮,会发现RadioButton会取消选中(丢失其状态),但在b.aspx页面执行同样的操作,RadioButton不会丢失,因为ViewState给它保存了状态. 您可以在运行界面点击浏览器菜单”查看”->“源文件”,打开Html代码文件,找到加密后的ViewState,类似于下面:

其实ViewState实现原理也是将一些信息放到隐藏的一个控件中,并且asp.net生成的ViewState信息
是存储在客户端的

这里要注意的一点是:

只有当格式为*.aspx文件,并且控件具有属性:”runat=server”时,回送功能才能打开

3. Html控件与Web控件最大的区别是它们对事件处理的方法不同。对于Html窗体控件,当引发一个事件时,浏览器会处理它。但对于Web控件,事件仅由浏览器生成,但浏览器不会处理它,客户端要给服务器发个信息,告诉服务器处理事件。 不过有些事件,比如:

按下键/移动/鼠标等事件,Asp.net中没有这些事件(因为这些事件即时性强,服务器处理得不够及时),这时候Html控件就发挥其作用了,结合Html事件

协助完成.
[/quote]

往后翻了n页,才找到一条比较详细的英文资料 http://www.codecomments.com/archive289-2005-9-607043.html

[quote]
This can be confusing to new ASP.Net developers. In fact, it is important to distinguish between several different types of ASP.Net Controls. Let me elaborate, if I may:

To begin with, let’s start with the parent NameSpace/Class for all ASP.Net Controls: System.Web.UI.Control. All ASP.Net Controls inherit this class.

Under this, there are about a dozen different classes and NameSpaces. I will only mention the most important ones here:

System.Web.UI.HtmlControls.HtmlControl

This is the base class from which all HtmlControls are derived. An HtmlControl is, at the very least, a simple, client-side HTML element, such as (Label),

(HtmlForm), or

(HtmlTable). There is no server-side aspect to any HtmlControl, unless you add a runat=”server” attribute to it. Adding this attribute gives you server-side control over the client-side HTML. You can create an HtmlControl from any client-side
HTML element. There are several ready-made HtmlControls, and an HtmlGenericControl which you can use for any other HTML element.

System.Web.UI.TemplateControl

This is the base Class for any ASP.Net Control that uses an HTML Template. There are 2 ready-made classes in the CLR that inherit this class.
System.Web.UI.Page, and System.Web.UI.UserControl. Generally, when people talk about “Web Controls,” they are talking about HtmlControls, WebControls, or the UserControl class, and not the Page class, although the Page class is, in fact a “Web Control” (Note the space in the term, which distinguishes “Web Control” from the class WebControl).

A UserControl is a Templated Control that is a container for pure HTML and other Web Controls. Of all the “Web Controls” that are used frequently in ASP.Net, the UserControl is the only one that has an HTML Template. It allows a block of HTML and server-side Controls to be treated as a single unit, or Control.

System.Web.UI.WebControls

This is a NameSpace, not a class. It has 6 different top-level classes:

System.Web.UI.WebControls.Literal

This class is used to encapsulate pure HTML in a container. It does nothing else. As ASP.Net is fully object-oriented, any HTML in a template that is not a server-side control is encapsulated in a Literal Control at run-time. It can also be used to pop any block of HTML into a Page or Control at run-time.

System.Web.UI.WebControls.PlaceHolder

This class is used, quite literally, as a “place holder.” It renders no HTML, but as a “Web Control,” (System.Web.UI.Conrol) it has a Controls Collection to which any other Control can be added. As it exists in a certain location in a Page or other Control, any Control can be popped into it at run-time. A UserControl could be used for this, by not having anything in it. But what would the purpose of the Template be? This class is not Templated, so it is easier to work with for this purpose.

System.Web.UI.WebControls.Repeater
System.Web.UI.WebControls.RepeaterItem

These 2 WebControls comprise a Repeater Control. The Repeater is a container for RepeaterItems. In addition, it has properties that allow for the addition of a number of System.Web.UI.ITemplate classes for fomatting the data contained in it. A Repeater is a sort of hybrid. While it is not a Templated Control, it is hosted in a Templated Control, and the Templates in it are placed in the Template of the hosting Templated Control. It is used for binding aggregate data (arrays, Collections, etc) to a block of repeating HTML in any format desired.

System.Web.UI.WebControls.WebControl

This is the base class for most of the Controls that are often confused with HtmlControls. A WebControl is a Control that ALWAYS has a server-side component, and WebControls all share the same fields, properties and methods of System.Web.UI.WebControl. In addition, each WebControl has fields, properties, and methods that correspond uniquely to the type of HTML element that the WebControl renders and interacts with at run-time.

HtmlControls are, therefore, by nature, leaner (consume less resources) than WebControls, but have less functionality as well.

System.Web.UI.WebControls.Xml

This class displays XML without any formatting or using XSLT. It is genreally used to display embedded XML in a web page.

In summary, the term “Web Control” is a fairly common, and confusing term that is generally used to encompass HtmlControls, WebControls, and the UserControl ASP.Net System.Web.UI.Control classes. It is important to distinguish between what type of “Web Control” is being discussed. The main differences between these 3 types of Controls are:

HtmlControls are lightweight Controls that can represent pure HTML, or add server-side functionality to client-side HTML.

WebControls are Controls that always have a server-side class associated with them, and provide a common server-side functionality for working with various HTML elements, and specific functionality for specific HTML elements.

A UserControl is a Templated Control which has a Template file, a container for both pure HTML and server-side class references in it, and allows for server-side manipulation of the server-side Controls in it. It allows a block of HTML and server-side Controls to be treated as a single unit, or Control.[/quote]

不知道谁说得更正确呢?

 Posted by at 4:36 pm
June 2019
M T W T F S S
« Sep    
 12
3456789
10111213141516
17181920212223
24252627282930