Raise Server-Side Click Event of CheckBox in a DataGrid Template Column
In an ASP.Net web page, there is a GridView control to show data retrieved from the database. And there is a CheckBox control in the template column of the GridView. When user click on the CheckBox to select/unselect the row on the gridview, and highlight the selected rows.Problem You need to respond to the checkbox change event, and know which check box on which row fired the event. The checkbox does not automatically call the datagrid's ItemCommand, so how can we access the datagridItem t
Introduce to Data Storage Objects in ASP.NET
Learn about the five powerful ASP.NET storage mechanisms, and how to quickly identify which to use for a given situation.IntroductionIn this brief tutorial, we'll look at five different ASP.NET objects we can use to store data. Two of these, the Application and Session objects, should be pretty familiar to anyone coming from ASP. The other three, Context, Cache and ViewState are brand new to ASP.NET. Each object is ideal under certain conditions, varying only in scope (that is the length of time
Assign Shortcut key for ASP.Net Page Using Javascript
Shortcut key gives end user more friendly interactions and performance. In this blog I will demonstrate how to implement a shortcut key access for ASP.NET page controls, using Javascript.Detecting keystrokesThe key point here is to capture window event of web browser. As we all know, browser vendors start experimenting when there's no official standard, and these experiments, though occasionally useful, also cause incompatibilities. The key events are no exception: there are currently two proper
Custom Paging in ASP.NET 2.0 with SQL Server 2005
In web application it is a routine to paging data retrieved from the database. And in ASP.NET 2.0 it is very simple to paging data by enable the "AllowPaging" property of GridView. This solution works well when the database data amount is not very large. However, if you want to page through thousands, tens of thousands, or hundreds of thousandsof records the default paging model is not viable. 1. Paging Data with SQL Server 200create procedure [dbo].[P_GetPagedOrders2000](@startIndex i
C# DateTime.ToString() Usage Demonstration
Formatting of Date and Time is an routine in application devlopment. In this blog I would show you how to format a DateTime value using DataTime.ToString() method in a specific culture.1. Format PatternThe following table lists the standard DateTime format patterns associated with DateTimeFormatInfo properties. For more information, see Standard Date and Time Format Strings.The following table lists the custom DateTime format patterns and their behavior. For more information, see Custom Date and
Building Cascading DropDownList in ASP.Net Using jQuery and JSON
Cascading DropDownList is a technique where we populate a child DropDownList based on the parent DropDownList selection. It is often used in web applications. In this blog I will show you how to implement a cascading dropdownlist using jQuery and Json in ASP.Net.Let's begin with a real example.As shown in pictures above, when we select a Building in Home Building DropDownList, it will populate the HomeRoom DropDownList based on the HomeBuilding selected.Now let's take a look at the key points.1.
Javascript showModalDialog() Function
In Web application we can use window.showMadalDialog() to popup a modal window. Now let's take a deep look at how to use this function. 1. Syntaxvar vReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures]);parameters description:sURL - required. data type : string. It refer to the URL of target ducument to link to.vArguments - optional. data type : variant. It can be an object, an array. It is used to pass value to the target document. Using window.dialogArguments to retrieve the
prevent a Javascript Modal Window to open itself in a new window
I used window.showModalDialog() to open a modal window in my ASP.Net web application. When I click a Button control to do something, the page is postback, and this made the modal window reopen a new window for the page. This is not what I excpected.To prevent this unexpected action, you need to add the following html code inside <head> section of your ASP.NET page.<base target="_self" />If your page use a master page, you should definde a ContentPlaceHolder under <head&g
Javascript校验与正则表达式
1匹配简体中文字符/^([u4E00-u9FA5]|[uFE30- uFFA0])*$/gi2匹配Email地址/^[w-]+(.[w-]+)* @[w-]+(.[w-]+)+$/3匹配非负浮点数/^d+(.d+)?$/4防止SQL注入/ and | or | exec | insert | select | union | update | count | * | % | ‘ | = | + /5匹配数字/^d+$/6匹配浮点数/^(+|-)?d+($|.d+$)/7匹配英文字母/^[A-Za-z]+$/8匹配IP地址@"^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]).(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0).(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]
ASP.NET TextBox的TextChange事件禁用Enter键
当web Form的一个TextBox控件获得焦点时,按Enter键的默认行为是触发第一个Button按钮的Click事件,造成Postback。这并不总是我们所期望的。下面介绍一种在Web Form上禁用Enter键的方法,避免不必要的Postback。在ASP.NET 页面的HTML代码中加入:<script language="javascript"> function document.onkeydown() { if (event.keyCode == 13) { var e = event.srcElement; if (e.tagName == "INPUT" && e.type == "text") event.keyCode = 9; } } </script> [@more@]
AspNetPager分页控件的使用
想必很多人都用过AspNetPager web分页导航控件。本文提供入门级的使用指导,详细内容可参考在线帮助文档。假定你已经下载了AspNetPager控件。按照以下步骤:1. 将AspNetPager.dll拷贝到VS2005网站项目的bin目录下;2. 添加对AspNetPager.dll的引用;3. 在VS2005工具箱的“数据”Lab下添加,通过右键“选择项”,添加AspNetPager.dll文件。AspNetPager控件将出现在工具箱上;4. 将AspNetPager控件拖放到Web窗体上;5.设置其必需的属性:AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;AspNetPager1.PageSize = 20;控件根据RecordCoun
强制页面显示在框架里
场景:有些时候,你希望页面显示在frame里面。这样做的理由通常有:限制访问页面的唯一入口;不希望你的页面显示在别人的框架里。实现:将以下代码添加到你的HTML页面里。Code:<script language="JavaScript"> <!-- Hide from older browsers if (window == top) top.location.href = "~/Default.aspx"; // 在这里指定你希望显示的框架页 --> </script> [@more@]
ASP.Net页面浏览器“后退”功能的实现
ASP.Net 页面上有一“返回”按钮,单击返回到之前浏览的页面,与浏览器的“后退”按钮具有等同效果。代码如下。在“返回”按钮的Click事件处理程序中添加:this.RegisterClientScriptBlock("E", "<script language=javascript>history.go(-2);</script>");或者Response.Write("<script language=javascript>history.go(-2);</script>");说明:这里应是-2,而不是-1。因为“返回”按钮Postback,浏览器重新请求了该页面。[@more@]