随笔分类 -  ASP.NET

上一页 1 ··· 39 40 41 42 43 44 45 46 47 ··· 54 下一页
摘要:asp.net有一个验证控件CustomValidator,一直没有机会使用过,今天有时间做了一个测试。如果你以前写Web站点时,常使用Javascript来做客户端验证的话,这个绝对可以使用的一个验证控件。下面Insus.NET做的例子,是让一个TextBox不能为空。在aspx写上一个TextBox 和一个Button,铵钮事件没有写什么,只是做postBack而已,另外一个就是不能少了主角asp:CustomValidator自定义验证控件。View Code <asp:TextBoxID="TextBox1"runat="server"&g 阅读全文
posted @ 2011-05-26 17:06 Insus.NET 阅读(1052) 评论(0) 推荐(1) 编辑
摘要:平常时,是因为多页共同的部分,可以开发为UserControl(用户控件),这样好维护。在网页设计时,哪一个网页需要,把用户控件拉(注册)进去即可。如:View Code 1<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"%>23<%@RegisterSrc="~/Header.ascx"TagName="Header"TagPref 阅读全文
posted @ 2011-05-26 10:42 Insus.NET 阅读(1029) 评论(2) 推荐(1) 编辑
摘要:或许你有做过,接过美工做好生成的Html的前台网页,开始写程序,你会知道有些简单的数据源绑定已经被美工做好了。如下:View Code <asp:DropDownListID="DropDownList1"runat="server"><asp:ListItemText="求购"></asp:ListItem><asp:ListItemText="出租"></asp:ListItem><asp:ListItemText="家政"& 阅读全文
posted @ 2011-05-25 14:05 Insus.NET 阅读(344) 评论(0) 推荐(1) 编辑
摘要:动态产生一个TextBox控件,还要在这个文本框输入的文本是靠右对齐。protectedvoidPage_Load(objectsender,EventArgse){//new一个TextBoxTextBoxtextBox=newTextBox();//添加样式,靠右对齐textBox.Attributes.CssStyle.Add("text-align","right");//把TextBox加入至form中去this.form1.Controls.Add(textBox);}网页在run的效果:ViewSource,可以看到它产生的html,20行 阅读全文
posted @ 2011-05-25 12:59 Insus.NET 阅读(1543) 评论(0) 推荐(1) 编辑
摘要:在程序开发中,Insus.NET使用Cookie时,很少使用如http://www.cnblogs.com/insus/articles/2055310.html的写法。习惯写成Cookie集合,什么叫做Cookie集合,即是说一个Cookie,它拥有多个值。下面一系列演示,是怎样创建Cookie集合与使用。InsusBizusingSystem;usingSystem.Web;///<summary>///SummarydescriptionforInsusBiz///</summary>publicclassInsusBiz{privatestaticHttpRes 阅读全文
posted @ 2011-05-25 10:15 Insus.NET 阅读(1889) 评论(5) 推荐(1) 编辑
摘要:某些值在数据库存储为BIT,在asp.net显示时,它会显示为True或False。但实际情况之下,我们需要它显示通俗语言表达。如某种状态为开或关等。在asp.net显示,可以有好几种去显示,第一种,你可以使用CheckBox来表示状态,True将显示选中的效果,反之,是非选中的效果。而使用CheckBox也有两种情形,一种是CheckBox摆放在非Data控件模板中,直接放在网页中<asp:CheckBoxID="CheckBox1"runat="server"/>cs:this.CheckBox1.Checked=(bool)dataRo 阅读全文
posted @ 2011-05-25 08:44 Insus.NET 阅读(2655) 评论(11) 推荐(1) 编辑
摘要:在做asp.net开发时,为了存储一些信息,Insus.NET常常是Session与Cookie同时使用。Session资料在Insus.NET博客上会找到很多相关的,而Cookie相关的资料相对很少,所以想补充一下。下面是写Cookie的语法:Response.Cookies["曲奇名称"].Value="Insus.NET";读Cookie的语法:if(Request.Cookies["曲奇名称"]!=null){stringcookieValue=Request.Cookies["曲奇名称"].Value.T 阅读全文
posted @ 2011-05-24 13:08 Insus.NET 阅读(909) 评论(0) 推荐(1) 编辑
摘要:这段时间,需要把一些C#处理的逻辑程序,搬移至SQL的存储过程中去。下面这个例子,就是怎样使用SQL的IN去替换C#的“||”参考代码,cs:View Code boolhub=false;boolstore=false;if(dataRow["Warehouse"].ToString()=="CF3"||dataRow["Warehouse"].ToString()=="CW2"){hub=true;}else{store=true;}这段代码,经Insus.NET移至SQL的存储过程之后,变为:View Cod 阅读全文
posted @ 2011-05-20 13:59 Insus.NET 阅读(478) 评论(0) 推荐(2) 编辑
摘要:你可以参考这篇:http://www.cnblogs.com/insus/articles/2050790.htmlInsus.NET觉得它写得很不理想。因为不想写得这样复杂,或者有其它ID变化的可能,如:ContentPlaceHolderID="ContentPlaceHolder1" 有可能变为ContentPlaceHolderID="ContentPlaceHolder3",ID="TextBox1"也有可能变为ID="MemberName" 等。在目标页,得需要写判断是否存在,是否为NULL,如果不这样 阅读全文
posted @ 2011-05-19 11:00 Insus.NET 阅读(1583) 评论(2) 推荐(2) 编辑
摘要:下面这个例子是演示在MasterPage母板下面。例子始起页放一个TextBox和一个Button,并用PostBackUrl来导向目标页。如:View Code <asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server"><asp:TextBoxID="TextBox1"runat="server"></asp:TextBox><asp:Button 阅读全文
posted @ 2011-05-19 10:31 Insus.NET 阅读(994) 评论(0) 推荐(1) 编辑
摘要:获取图片的宽度与高度,这种情形并非是在文件上传时获取,而是直接去读取图片文件来取得。可以在System.Drawing名称空间之下有一个Image类别,这个类别还有一个FromFile()方法,这样我们可以去读取图片了。.aspx.cs:View Code stringfile="Koala.jpg";//new一个Image实例,并读取图片System.Drawing.ImageinsusImage=System.Drawing.Image.FromFile(Server.MapPath(file));//实例就可以取得宽度与高度了。this.Literal1.Text= 阅读全文
posted @ 2011-05-17 10:27 Insus.NET 阅读(1049) 评论(0) 推荐(1) 编辑
摘要:今天在论坛上看到有网友有这样的需求,就是“在asp.net页面中如何点图片就在asp.net页面中堪入的SWF文件中显示这张图片”。记得Insus.NET以前也曾经实现过。既然有人也需求,那把它分享出来。下面提供的代码与方法,已经最大化简化。首先创建一个swf类别:View Code usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;///<summary>///SummarydescriptionforSwf///</summary>namespaceInsus.N 阅读全文
posted @ 2011-05-17 09:28 Insus.NET 阅读(805) 评论(0) 推荐(1) 编辑
摘要:Server Error in '/InsusTutorials' Application. The value '5/15/2012' of the MaximumValue property of 'RangeValidator1' cannot be converted to type 'Date'.Description: An unhandled exception occurred during the execution of the current web request. Please review the st 阅读全文
posted @ 2011-05-16 16:48 Insus.NET 阅读(905) 评论(0) 推荐(1) 编辑
摘要:再有网友问及此问题。Insus.NET重新写个简单的例子,此次把Flv Object 代码写入cs类别中。在应用时,只new它即可。Flv objFlv = new Flv();objFlv.Player();你在这里就可以看到它:View Code publicstringPlayer(){stringtexts=string.Empty;stringconfig="1:自动播放|0:连续播放|100:默认音量|0:控制栏位置|2:控制栏显示|0x000033:主体颜色|60:主体透明度|0x66ff00:光晕颜色|0xffffff:图标颜色|0xffffff:文字颜色|:logo 阅读全文
posted @ 2011-05-16 09:46 Insus.NET 阅读(3991) 评论(3) 推荐(4) 编辑
摘要:Server Error in '/Website1' Application. Must declare the scalar variable "@Author".Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 阅读全文
posted @ 2011-05-13 16:44 Insus.NET 阅读(1974) 评论(0) 推荐(1) 编辑
摘要:Server Error in '/Website1' Application. Could not load file or assembly 'Microsoft.ReportViewer.ProcessingObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.Description: An unhandled 阅读全文
posted @ 2011-05-13 12:59 Insus.NET 阅读(6974) 评论(0) 推荐(1) 编辑
摘要:Server Error in '/Website1' Application. Configuration ErrorDescription: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: Co 阅读全文
posted @ 2011-05-13 10:35 Insus.NET 阅读(1726) 评论(0) 推荐(1) 编辑
摘要:DataList控件,每笔记录会放置一个Button,让用户Click这个Button,将会获取这笔记录相关信息。下面这个例子演示是怎样获取记录的主键。.aspx,你需要为Datalist写OnItemCreated事件和定义DataKwyField这样才可以定义记录铵钮事件与取得记录的主键值。View Code <asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager><asp:UpdatePanelID="UpdatePane 阅读全文
posted @ 2011-05-12 10:15 Insus.NET 阅读(1442) 评论(0) 推荐(1) 编辑
摘要:如果你经常光临Insus.NET的博客,你会留意到有一篇博文 Asp.net读取Excel文件 那只是列出Excel两个版本的连接语句。但是你的专案在应用时,也许不能固定用户只上传某一种版本的Excel文件而你在专案中取舍使用哪一种连接字串,所以你会尝试使用下面方法去解决,判断上传的Excel文件是什么版本的:View Code publicstaticstringGetExcelConnectionString(stringfile){stringconnectionString=string.Empty;stringfileExtension=file.Substring(file.Las 阅读全文
posted @ 2011-05-05 16:13 Insus.NET 阅读(2686) 评论(0) 推荐(1) 编辑
摘要:Asp.net做Web开发,经常会动态添加控件,如果连续添加web控件,如果不经过一些细节处理,这些控件为集中为一团。这样还需要添加一些HtmlGenericControl为分隔。有关HtmlGenericControl更详细可参考:http://msdn.microsoft.com/en-us/library/7512d0d0(v=VS.100).aspx它是在System.Web.UI.HtmlControls名称空间之下。接下来开始实例演示:.aspx:<asp:PlaceHolderID="PlaceHolder1"runat="server&quo 阅读全文
posted @ 2011-05-05 11:08 Insus.NET 阅读(3761) 评论(0) 推荐(2) 编辑

上一页 1 ··· 39 40 41 42 43 44 45 46 47 ··· 54 下一页