创建简单的ASP.NET服务器控件 [英] Create Simple ASP.NET Server Control
本文介绍了创建简单的ASP.NET服务器控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
我想在VS 2010中创建一个称为数字文本框的服务器控件
从文本框继承的类,但仅接受数值
当您将此控件拖到页面准备使用"时
所有代码都在Component
内部
我有2种方法
1)Java脚本
2)Ajax
你向我解释:
哪一个?
和
怎么样?
我是这项技术的初学者,请完整说明;
感谢ToAdvance
Hi To All
I Want Create a Server Control in VS 2010 that called numeric textbox
a class inherited from textbox but only accept Numeric Value
when you drag this control to page Is Ready To Use
All Codes are in inside Component
I Have 2 Ways
1) Java Script
2) Ajax
You Explain Me :
Which?
and
How?
I am Beginner on this Technology, Please Explain Completely;
Thank To Advance
推荐答案
请使用javascript
找到以下带有文本框验证的代码仅具有数字值
Hi,
Please find the below code with textbox validation has only numeric value using javascript
<head runat="server">
//Javascript code:
<script type="text/javascript">
function ValidateCCNum(ccNum) {
var ccno = ccNum.value;
if (isNaN(ccno)) {
alert("Textbox value should be numeric");
ccNum.focus();
ccNum.value = null;
return false;
}
return true;
}
</script>
</head>
<%--In Aspx file call this function as below--%>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<asp:textbox id="txtCCDNo" onblur="ValidateCCNum(this)" runat="server"> </asp:textbox>
</asp:Content>
在aspx客户端页面中运行此代码
Run this code in aspx client page
这篇关于创建简单的ASP.NET服务器控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文