真爱无限的知识驿站

学习积累技术经验,提升自身能力

asp.net自定义控件中注册Javascript的问题

.Net 代码:

   

    protected override void OnPreRender(EventArgs e)
        {
           
            base.OnPreRender(e);
            RenderJS();
        }
        private void RenderJS()
        {
            if (!Page.ClientScript.IsClientScriptBlockRegistered(SCRIPT_ID))//如果还没有注册语句,则注册
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(),SCRIPT_ID,SCRIPT_CONTENT);
            }
            
        }
        private const string SCRIPT_ID = "5B7A061B93D546A7A2601D56A8738DB9";//自定义标识Guid
        private const string SCRIPT_CONTENT = "<script type="text/javascript">
var CB4949501DA_checkDouble = function (data) {
var key = event.keyCode;
if ((key < 48 || key > 57) && key != 46 && key != 45) {
return false;
}
else {
if (key == 46) {
if (data.indexOf(".") != -1 || data.length == 0)
return false;
}
else if (key == 45) {
if (data.indexOf("-") != -1 || data.length != 0) {
return false;
}
}
}
return true;
}
var CB4949501DA_checkInt = function (data) {
var key = event.keyCode;

if ((key < 48 || key > 57) && key != 45) {
return false;
}
else {
if (key == 45) {
if (data.indexOf("-") != -1 || data.length != 0) {
return false;
}
}
else {
var input = String.fromCharCode(key)
var intData = parseInt(data + input);
if (intData > 2147483647 || intData < -2147483648) {
return false;
}
}
return true;
}
return true;
}
var <span style="color:#ff0000;">CB4949501DA_checkLong </span>= function (data) {
var key = event.keyCode;

if ((key < 48 || key > 57) && key != 45) {
return false;
}
else {
if (key == 45) {
if (data.indexOf("-") != -1 || data.length != 0) {
return false;
}
}
else {
var input = String.fromCharCode(key)
var longstrData = data + input
if (longstrData.length > 19) {
return false;
}
}
}
return true;
}
</script>
";


c#页面验证类DataValidate代码



using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;
namespace Tools.Common
{
    /// <summary>
    /// 页面验证类
    /// </summary>
    public class DataValidate
    {
        private static Regex RegPhone = new Regex(@"^(1d{10})|(d{3,4}[-]d{6,8})$");
        /// <summary>
        /// 纯数字,无正负号
        /// </summary>
        private static Regex RegNumber = new Regex("^[0-9]+$");
        /// <summary>
        /// 纯数字,可能有正负号
        /// </summary>
        private static Regex RegNumberSign = new Regex("^[+-]?[0-9]+$");
        /// <summary>
        /// 可能有有小数点的数字
        /// </summary>
        private static Regex RegDecimal = new Regex(@"^(d+[.]d+)|(d+)$");
        /// <summary>
        /// 可能有小数点,也有可能有正负号的数字
        /// </summary>
        private static Regex RegDecimalSign = new Regex(@"^[+-]?((d+[.]d+)|(d+))$"); //等价于^[+-]?d+[.]?d+$
        /// <summary>
        /// Email地址
        /// </summary>
        private static Regex RegEmail = new Regex("^[\w-]+@[\w-]+\.(com|net|org|edu|mil|tv|biz|info|com.cn)$");
        /// <summary>
        /// 是否有中文
        /// </summary>
        private static Regex RegCHZN = new Regex("[u4e00-u9fa5]");


生成(c#检查输入数据、web界面控件)代码的存储过程


GO  

/****** 对象:  StoredProcedure [dbo].[pro_GenerateCheckInput_webControl]    脚本日期: 08/13/2012 10:10:16 ******/  

SET ANSI_NULLS ON  

GO  

SET QUOTED_IDENTIFIER ON  

本人写的数据库常用函数(存储过程中经常要用到)

GO  

/****** 对象:  UserDefinedFunction [dbo].[fun_get_LowerFirst]    脚本日期: 08/04/2012 13:03:56 ******/  

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fun_get_comment]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))  

mssql方便的函数使用与游标使用练习

表数据:



winform将含有超过两列的DataTable绑定到combobox并有""请选择""或""全部""选择项


.Net winform:

        #region 显示多列DataTable到combobox
        /// <summary>
        /// 显示多列DataTable到combobox
        /// </summary>
        /// <param name="dataTable">含有超过两列的DataTable</param>
        /// <param name="comboBox">combobox控件名</param>
        /// <param name="TextColumn">显示的text对应的列</param>
        /// <param name="ValueColumn">value值对应的列</param>
        /// <param name="isNeedShowEmpty">是否显示‘请选择’</param>
        /// <param name="isNeedShowAll">是否显示‘全部’</param>
        public static void ToDataTableCombobox(DataTable dataTable, ComboBox comboBox, string TextColumn, string ValueColumn, bool isNeedShowEmpty, bool isNeedShowAll)
        {
            if (dataTable == null || comboBox == null || dataTable.Columns.Count == 0)
            {
                return;
            }
            DataTable dtnew = new DataTable();
            dtnew.Columns.Add("text");
            dtnew.Columns.Add("value");


winForm开发问题,vs的bug,Datagridview始终不能编辑!

如果更改Datagridview启用编辑为不选中

c#利用反射Assembly 对类和成员属性进行操作

        protected static void test()
        {
            //获取程序集
            Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();//Assembly.LoadFrom("test.dll"); 
            //获取模块
            Module[] modules = assembly.GetModules();
            foreach (Module module in modules)
            {
                Console.WriteLine("module name:" + module.Name);
            } 
            //获取类
            Type type = assembly.GetType("Reflect_test.PurchaseOrderHeadManageModel", true, true); //命名空间名称 + 类名
            //创建类的实例
            object obj = Activator.CreateInstance(type, true);


对Remoting进行封装,方便使用


using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Runtime.Remoting.Channels.Http;
using System.Runtime.Remoting.Channels;
using System.Xml;
using System.Runtime.Remoting;
using System.Collections;
namespace Tools
{
    /// <summary>
    /// Remote自定义操作类,更方便使用
    /// </summary>
    public class RemoteHelper
    {
        /// <summary>
        /// 服务端注册的端口信息
        /// </summary>
        public static IDictionary ServerHttpProp = new Hashtable();
        /// <summary>
        /// 客户端连接服务端的端口
        /// </summary>
        public static int ClientToServerPort = 8888;
        /// <summary>
        /// 服务端的http地址
        /// </summary>
        private string url = "";
        #region 单个实例  Instance
        private static readonly RemoteHelper instance = new RemoteHelper();
        /// <summary>
        /// 单个实例  Instance
        /// </summary>
        public static RemoteHelper Instance
        {
            get
            {
                return instance;
            }
        }
        #endregion


存储过程模拟加锁解锁


-- 获取锁

ALTER procedure [dbo].[pro_get_sys_ordr_lock_info](   

     @ORDR_HEAD_SEQ 编号,  

     @ORDR_TYP_CD VARCHAR(20)  

 )as  

begin   

<< < 19 20 21 22 23 24 25 26 27 28 > >>

Powered By Z-BlogPHP 1.7.3

Copyright 2024-2027 pukuimin Rights Reserved.
粤ICP备17100155号